Selenium Firefox Driver Download Directory

Setting a custom browser.download.dir for Firefox using Webdriver. Driver = webdriver.Firefox (firefox. Downloads directory is the one from the default.

Active4 years, 5 months ago

Ok so far i have my programing going to the website i want to download link from and selecting it, then the firefox dialogue box shows up and i don't know what to do. i want to save this file to a folder on my desktop. I am using this for a nightly build so i need this to work. Please help.

  • Selenium Webdriver - browser preferences for downloading files. Def __get_firefox_driver(self, download_dir). Selenium Webdriver.
  • SeleniumHQ / selenium. Or Legacy Firefox Driver. Download the firebug xpi file from mozilla and start the profile as follows.
  • How to Download files using Selenium in FireFox Browser Profile with example. What is MIME Type? How to set FF Browser Profile to download file in Selenium.

Here is my code that grabs the download link from the website:

alecxe
346k78 gold badges728 silver badges933 bronze badges
Jerad BillJerad Bill

2 Answers

You need to make Firefox save this particular file type automatically.

This can be achieved by setting browser.helperApps.neverAsk.saveToDisk preference:

More explanation:

  • browser.download.folderList tells it not to use default Downloads directory
  • browser.download.manager.showWhenStarting turns of showing download progress
  • browser.download.dir sets the directory for downloads
  • browser.helperApps.neverAsk.saveToDisk tells Firefox to automatically download the files of the selected mime-types

You can view all these preferences at about:config in the browser. There is also a very detailed documentation page available here: About:config entries.

Besides, instead of using xpath approach, I would use find_element_by_partial_link_text():

Selenium Firefox Driver Download

Also see:

Community
Seleniumalecxealecxe

Download Firefox For Selenium

346k78 gold badges728 silver badges933 bronze badges

If the application is generated dynamically (mime-types) using Chrome browser will be a better approach since the Chrome will not open the file download pop-up.But multiple download option should be enabled if you need multiple downloads.

Ravinath EdirisingheRavinath Edirisinghe

Selenium Firefox Driver Download Directory

Not the answer you're looking for? Browse other questions tagged pythonfirefoxseleniumselenium-webdriver or ask your own question.