Selenium Webdriver in Python - files download directory change in Chrome preferences

前端 未结 6 1580
逝去的感伤
逝去的感伤 2020-11-27 05:09

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

6条回答
  •  温柔的废话
    2020-11-27 05:41

    The following worked for me:

    chromeOptions = webdriver.ChromeOptions()
    prefs = {"download.default_directory" : "/some/path"}
    chromeOptions.add_experimental_option("prefs",prefs)
    chromedriver = "path/to/chromedriver.exe"
    driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chromeOptions)
    

    Source: https://sites.google.com/a/chromium.org/chromedriver/capabilities

提交回复
热议问题