3

I'm using Selenium to download different files of a web. My initial configuration when i run the program is:

download_dir = "/Users/Downloads" 
options = webdriver.ChromeOptions()

profile = {"plugins.plugins_list": [{"enabled": False, "name": "Chrome PDF Viewer"}], # Disable Chrome's PDF Viewer
           "download.default_directory": download_dir , 
           "download.extensions_to_open": "applications/pdf","download.prompt_for_download": False}
options.add_experimental_option("prefs", profile)

I would like to download the differents files in differents folders, so I understand, that I should update of value of the path in "download.default_directory". My problem is that I don't know how do that. I update the new value before download the file,

download_dir = "/Users/Download"+exp1
driver.find_element_by_xpath('//*[@id="myTab"]/tbody/tr[2]/td[3]/div/a[3]').click()

but it saves in first path "/Users/Downloads"

Is it possible to update "download.default_directory" to save in different folder?

Andrei Suvorkov
  • 5,559
  • 5
  • 22
  • 48
Davicholo
  • 33
  • 1
  • 4

1 Answers1

3

It is not possible to change download directory after creating a webdriver instance. To solve your problem, you have to create a new webdriver instance every time you want to change download directory.

Andrei Suvorkov
  • 5,559
  • 5
  • 22
  • 48
  • Thank you so much Andrei. Also I have seen how to do it in: https://stackoverflow.com/questions/23896625/how-to-change-default-download-folder-while-webdriver-is-running – Davicholo Aug 02 '18 at 10:14