[Python] Python Selenium Webdriver - Dynamically change download directory

Discussão em 'Python' iniciado por Stack, Fevereiro 4, 2025.

  1. Stack

    Stack Membro Participativo

    To explicitly define the download directory prior to defining the selenium webdriver we use the following code:

    chromeOptions = webdriver.ChromeOptions()
    prefs = {"download.default_directory" : "C:/data/cline"}
    chromeOptions.add_experimental_option("prefs",prefs)
    chromePath = "path to chromedriver"

    driver = selenium.webdriver.chrome.webdriver.WebDriver(executable_path=chromePath, port=0, chrome_options=chromeOptions, service_args=None, desired_capabilities=None, service_log_path=None)


    I want to download a number of files, each to a different (newly created) directory. Is it possible to change the download directory after defining driver?

    Continue reading...

Compartilhe esta Página