I'm using Selenium Webdriver (in Python) to automate the downloading of thousands of files. I want to set Chrome's download folder programmatically. After reading this, I tried this:
chromepath = '/Users/thiagomarzagao/Desktop/searchcode/chromedriver'
desired_caps = {'prefs': {'download': {'default_directory': '/Users/thiagomarzagao/Desktop/downloaded_files/'}}}
driver = webdriver.Chrome(executable_path = chromepath, desired_capabilities = desired_caps)
No good. Downloads still go to the default download folder ("/Users/thiagomarzagao/Downloads").
Any thoughts?
(Python 2.7.5, Selenium 2.2.0, Chromedriver 2.1.210398, Mac OS X 10.6.8)
If anyone is still having trouble and the above solutions didn't work, I found adding a following slash ('\') to my download path.
Mine looked like this:
For anybody still wondering why their implementation doesn't work: You have to put the FULL PATH for it to work. e.g. '/Users/you/dlfolder' won't work, while 'C:/Users/you/dlfolder' will.
I try all the anwsers in this question, but it doesn't work for my in Ubuntu 16.10. So I add the change with os.environ for the variable XDG_DOWNLOAD_DIR. Which doesn't work, but I think that it helps.
That is:
The really change that works perfectly for me is setup the download folder via the command xdg-user-dirs-update through a system call in execution time:
So, all my code related to setup the download dir is the following:
I think you also need
Using the dictionary directly in a Chrome 'Prefrences' file, on a local windows install of chrome Version 28.0.1500.95 m, with the following download options:
I get the default location, versus the desktop. When I change it to this:
I get the desktop location.
Try the following:
The following worked for me:
Source: https://sites.google.com/a/chromium.org/chromedriver/capabilities