Reputation: 33
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?
Upvotes: 3
Views: 3567
Reputation: 5637
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.
Upvotes: 3