close

[Solved] Selenium Webdriver in Python – files download directory change in Chrome preferences

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Selenium Webdriver in Python – files download directory change in Chrome preferences in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Selenium Webdriver in Python – files download directory change in Chrome preferences Error Occurs?

Today I get the following error Selenium Webdriver in Python – files download directory change in Chrome preferences in python.

How To Solve Selenium Webdriver in Python – files download directory change in Chrome preferences Error ?

  1. How To Solve Selenium Webdriver in Python – files download directory change in Chrome preferences Error ?

    To Solve Selenium Webdriver in Python – files download directory change in Chrome preferences Error If anyone is still having trouble and the above solutions didn't work, I found adding a following slash ('\') to my download path.

  2. Selenium Webdriver in Python – files download directory change in Chrome preferences

    To Solve Selenium Webdriver in Python – files download directory change in Chrome preferences Error If anyone is still having trouble and the above solutions didn't work, I found adding a following slash ('\') to my download path.

Solution 1

If anyone is still having trouble and the above solutions didn’t work, I found adding a following slash (‘\’) to my download path.

Mine looked like this:

    if browser == 'chrome':
        options = webdriver.ChromeOptions()
        options.add_argument("--start-maximized")
        prefs = {"profile.default_content_settings.popups": 0,
                 "download.default_directory": r"C:\Users\user_dir\Desktop\\", # IMPORTANT - ENDING SLASH V IMPORTANT
                 "directory_upgrade": True}
        options.add_experimental_option("prefs", prefs)
        return webdriver.Chrome(executable_path=Base.chromedriver_dir, chrome_options=options)

Solution 2

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, options=chromeOptions)

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read