Search code examples
pythonselenium-webdriverselenium-chromedriver

Selenium 4.14 - ChromeDriver - default download directory not working


I cannot set a default download directory for my driver.

My code is the following:

    def setup_method(self):
        time.sleep(1)
        options = Options()
        prefs = {'download.default_directory': r"C:\Test",
                 'download.prompt_for_download': True,
                 'download.directory_upgrade': True,
                 'safebrowsing.enabled': True
                 }
        options.add_experimental_option("detach", True)
        options.add_experimental_option("prefs", prefs)

        options.add_argument('--disable-extensions')
        options.add_argument('--disable-dev-shm-usage')
        self.browser = webdriver.Chrome(options=options)

Still when I download somehting it goes to Downloads folder. It was working before when I was using local webdriver but since Selenium has implemented the driver manager, I dont use service argument.

Could you please help what am I missing?

[SOLUTION HERE: https://stackoverflow.com/a/76176954/22775020]


Solution

  • SOLUTION HERE: https://stackoverflow.com/a/76176954/22775020

    ...'savefile.default_directory': self.download_directory... should be added