How to download a file using Selenium's WebDriver?
Basically I want to at least check that a download-able file exists / download link works and preferably get stuff like the file size too.
Here's an example:
link = self.browser.find_element_by_link_text('link text') href = link.get_attribute('href') download = self.browser.get(href) print download
That fourth line prints "None", presumably because I haven't manually clicked the Save button, and even if I had, I doubt WebDriver would be able to "see" the file.
Any ideas? I'm using Firefox as my browser-under-test, and I understand that the file handling for downloads is somewhat browser and/or OS-specific.
Maybe it's better to see [this]. : http://stackoverflow.com/questions/18439851/downloading-file-using-selenium
One potential solution is to obtain the URL for the file via Selenium, create a (non-Selenium) connection, copy Selenium's cookies to the connection (if necessary), and download the file. Since this method utilizes non-Selenium APIs to download the file, it will work with (or without) any browser. For more info, see my answer here: https://stackoverflow.com/questions/16746707/how-to-download-any-file-and-save-it-to-the-desired-location-using-selenium-webd/46774849#46774849
+1 but "Provide context for links Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline." as stated here: http://sqa.stackexchange.com/help/how-to-answer