How to control the download of files with Selenium + Python bindings in Chrome

The path you declared for the default directory is invalid. Either escape the back slashes or provide a literal string.

options = webdriver.ChromeOptions()
options.add_experimental_option("prefs", {
  "download.default_directory": r"C:\Users\xxx\downloads\Test",
  "download.prompt_for_download": False,
  "download.directory_upgrade": True,
  "safebrowsing.enabled": True
})
driver = webdriver.Chrome(chrome_options=options)

Here are the available preferences:

https://cs.chromium.org/chromium/src/chrome/common/pref_names.cc

Leave a Comment