I want to save a web site and download file into specific folder. How can I do it with webdriver? In Chrome and Firefox I just press Ctrl+S then select a folder to save the current website. Is there any way to do it in selenium webdriver? Can PhantomJS do it?
Asked
Active
Viewed 3,121 times
4
-
Do you want to save the current open webpage or the complete website? – Abhijeet Vaikar Mar 13 '14 at 06:13
-
you can check this out: [HTTrack](http://www.httrack.com/) – Abhijeet Vaikar Mar 13 '14 at 06:15
-
"Do you want to save the current open webpage or the complete website?" yes, I want to save it with specify name and folder – Minh Le Mar 13 '14 at 06:52
-
Abhijeet Vaikar i checkec HTTrack, I mean that When I open a website via "selenium webDriver" some time i want to save the web site in local to check content (like "Ctrl + S" in FireFox or Chrome) but I don't now how to set name and folder to save in Webdriver – Minh Le Mar 13 '14 at 07:16
-
I want to save a complete website like "Ctrl + S" in Chorme or Firefox – Minh Le Dec 16 '14 at 01:59
2 Answers
0
My conclusion is that you cannot do this with the current features of selenium.
Why? The two available features from Selenium that are relevant for your needs are:
- taking screenshot
- and retrieving the html source of the page
However those won't match what is done with a Ctrl+S.

thesmash
- 599
- 6
- 9
-
-
2Hi, the question is not about retrieving html of the current page but to simulate the ctrl+s behavior, which is doing more than retrieving the current page html. Ctrl+s will save resources of the page and generate a local folder tree. – thesmash Dec 15 '14 at 21:50
-
Agree with thesmash. @Tooklkit, you should be the one who needs to read the question more carefully. – weefwefwqg3 Sep 13 '18 at 02:32
0
Automate pressing Control S then switch to the save menu and save the html file. Here's how I did it with Python:
driver.send_keys("u'\ue009'"+"s")
driver.switch_to.window("Window_ID")
driver.find_element_by_id("SAVE_button").click()
Use the inspect tool to find the Window name and the necessary Id's.
see: http://selenium-python.readthedocs.org/api.html#selenium.webdriver.common.keys.Keys.CONTROL

swsmith
- 238
- 2
- 6
-
Could be that the API changed since the original post, but "send_keys" is not a method available on the webdriver object any longer. It does exist either on elements in the page or on an ActionChain object. – Brent Writes Code Jun 17 '18 at 21:33