0

I'm using Selenium in Python and I'm trying to change the download path. But either this:

prefs = {"download.default_directory": "C:\\Users\\personal\\Downloads\\exports"}
options.add_experimental_option("prefs", prefs)`

or this

options.add_argument("--download.default_directory --C:\\Users\\personal\\Downloads\exports")`

are not working.

In first case I also get the error

from invalid argument: unrecognized chrome option: prefs

Can someone help?

undetected Selenium
  • 151,581
  • 34
  • 225
  • 281
  • Does this answer your question? [Downloading a file at a specified location through python and selenium using Chrome driver](https://stackoverflow.com/questions/35331854/downloading-a-file-at-a-specified-location-through-python-and-selenium-using-chr) – JAdel Apr 02 '22 at 09:49
  • if you have a https://stackoverflow.com/help/minimal-reproducible-example then this would help users answer in more detail. – D.L Apr 02 '22 at 10:41

1 Answers1

0

To change the download directory/path you can use the following code block:

compatible code

from selenium.webdriver.chrome.options import Options

options = Options()
options.add_experimental_option("prefs", {
  "download.default_directory": r"C:\Data_Files\output_files"
  })
s = Service('C:\\BrowserDrivers\\chromedriver.exe')
driver = webdriver.Chrome(service=s, options=options)

References

You can find a couple of relevant detailed discussions in:

undetected Selenium
  • 151,581
  • 34
  • 225
  • 281