0

I am trying to reassign the Chrome download default directory when scraping a .csv file with Selenium. I've tried using Chromedriver 77, 76, and 75, but continue to get the same error... not sure what I'm doing wrong here.

### Set Chrome Options ###
opts = webdriver.ChromeOptions()

prefs = {
"download.default_directory": "C:/Users/WTC/Desktop",
"download.prompt_for_download": False,
"download.directory_upgrade": True
}

opts.add_experimental_option("prefs",prefs)
opts.add_argument("test-type")
opts.add_argument("--disable-web-security")
opts.add_argument("--allow-running-insecure-content")

chromedriver = "C:/Users/WTC/AppData/Local/Programs/Python/Python37-32/Scripts/chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver, options=opts)
BorangeOrange1337
  • 182
  • 1
  • 1
  • 20
  • Possible duplicate of https://stackoverflow.com/questions/40654358/how-to-control-the-download-of-files-with-selenium-python-bindings-in-chrome – Dan-Dev Sep 07 '19 at 18:46
  • Possible duplicate of [How to control the download of files with Selenium + Python bindings in Chrome](https://stackoverflow.com/questions/40654358/how-to-control-the-download-of-files-with-selenium-python-bindings-in-chrome) – Dan-Dev Sep 07 '19 at 18:46

2 Answers2

4

default directory file path was not being read correctly, this did the trick....

"download.default_directory": r"C:\Users\WTC\Desktop"

BorangeOrange1337
  • 182
  • 1
  • 1
  • 20
0

In my case, it worked by removing the 'r' and changing the backslashes

"download.default_directory": "C:\\Users\\WTC\\Desktop"

Asmita
  • 1
  • 1