5

I was originally going to ask this question just for Safari. However, I've yet to find the answer for Edge, Opera, Safari and IE (although I think it might not be possible for the latter). Since there seems to be no goto place for this simple question I figured this could all be put into one post.

Questions: Is this possible for Edge, Opera, Safari and IE? If so, how?

Here is the code for Chrome and Firefox for reference

# Chrome
options = selenium.webdriver.ChromeOptions()
options.add_experimental_option("prefs", {"download.default_directory": download_directory})
driver = selenium.webdriver.Chrome(chrome_options=options)

# Firefox
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.dir", download_directory)
driver = webdriver.Firefox(firefox_profile=profile)

Note that if it's possible via some other language bindings then I'm sure it is via python. So feel free to post non-python solutions and I'll translate once I have the hint!

Andrew Parker
  • 1,425
  • 2
  • 20
  • 28
  • refer this link : https://stackoverflow.com/questions/18510965/how-to-set-internetexplorerdriver-download-directory/18511711#18511711 –  Jul 18 '17 at 06:02
  • Can you narrow down your Question to either of the browsers `Edge, Opera, Safari and IE`? Thanks – undetected Selenium Jul 18 '17 at 08:00
  • @DebanjanB - you want me to ask only for one specific browser? Or change the title to specify `Edge, Opera, Safari and IE`? – Andrew Parker Jul 18 '17 at 09:22
  • @AndrewParker As of now your Question mentions 4 browsers e.g. Edge, Opera, Safari and IE. So it requires 4 distinct Answers to Answer your Question. As an alternate if you can narrow down your Question to one specific browser chances are high you will get a distinct Answer. Thanks – undetected Selenium Jul 18 '17 at 09:26
  • My goal was to avoid people having to go through 5/6 different searches as this question seems to be asked in different places and inconclusively answered. I thought it'd be nice to have a single answer in one place. However, if I I'm really forced choose then I'll pick Safari first as it *appears* to be possible for Safari. – Andrew Parker Jul 18 '17 at 09:57
  • On firefox you need to set additional parameters to specify that the download window should not open, that it should not use the default directory and that it should automatically download the specified mime type. Have a look at this question: https://stackoverflow.com/questions/25251583/downloading-file-to-specified-location-with-selenium-and-python – robertspierre Apr 14 '19 at 09:30

1 Answers1

0

Internet Explorer doesn't use profiles. It's a limitation of the browser itself, not the IE driver. As such, there is no way to automatically download files to a specified location with Internet Explorer.

and for Safari check this link:how to handle file downlaod for selenium webdriver for safari

  • Thanks. I'd found both of those. I was hoping that for Edge things might have progress in 2 years and there may be a new answer (I don't care that much about IE). For Safari, I'm looking through the code and it seems that the Java code posted there effectively just passes `"safari.options.dataDir"` as a capability to the driver. I've tried this on python and no luck so far. I will try again and investigate more carefully to see what's going on. – Andrew Parker Jul 18 '17 at 10:00
  • I suspect this no longer works now that Safari natively supports a webdriver. Selenium switched to using the Apple safariwebdriver as opposed to their js extension. I haven't found much in the way of docs on this yet. Perhaps this is no longer possible though. – Andrew Parker Jul 19 '17 at 02:32