I'm trying to save a webpage through selenium
and "ctrl+s" via pyautogui
. But I couldn't change the directory for saving when the save file window comes. The examples I could find about it are to save the screenshot in a specified directory. However, I'd like to save exactly in the current working directory, in case it may need to work in other computers.
page = webdriver.Chrome(executable_path='chromedriver.exe')
page = page.get(url)
pyautogui.hotkey('ctrl', 's')
time.sleep(3)
path = os.getcwd()
pyautogui.typewrite('foo' + '.html')
pyautogui.press('enter')
Is it possible to insert os.getcwd()
somewhere in this code? I tried to add os.getcwd()
at some places(such as (path + 'foo' + '.html')
) but it didn't work, as expected. Or is there any other way to do?