selenium: [🐛 Bug]: download.default_directory after update Chrome and chromedriver not working

What happened?

After update chrome and chromedriver to version 110 chromedriver_mac_arm64 https://chromedriver.chromium.org/downloads download.default_directory stopped working. Before today’s update everything worked. Please let me know if I need to change anything in the code. The file is downloaded but to the main folder with the application and not to the designated path

chrome_options = Options() prefs = {‘download.default_directory’: ‘./x/x’} chrome_options.add_experimental_option(‘prefs’, prefs) driver = webdriver.Chrome(options=chrome_options)

How can we reproduce the issue?

chrome_options = Options()
prefs = {'download.default_directory': './x/x'}
chrome_options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(options=chrome_options)

Relevant log output

The file is downloaded but to the main folder with the application and not to the designated path

Operating System

macOS Monterey 12.0.1

Selenium version

4.4.3

What are the browser(s) and version(s) where you see this issue?

Chrome 110

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 110.0.5481.77

Are you using Selenium Grid?

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 41 (5 by maintainers)

Commits related to this issue

Most upvoted comments

–headless --> download path not working –headless=new -> maximizing not working

That is the exactly the same problem I have.

I had the exact same issue where the following worked in previous ChromeDriver versions but it stopped working in 110.0.5481.77 on Windows 10:

chrome_options = Options()
prefs = {'download.default_directory': './x/x'}
chrome_options.add_argument("--headless")
chrome_options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(options=chrome_options)

I had to make 2 changes:

  1. Use the new headless argument as suggested by the previous answers:
chrome_options.add_argument("--headless=new")
  1. Also Add a trailing slash to the folder path:

prefs = {'download.default_directory': '.\\x\\x\\'}

This now works:

chrome_options = Options()

# For windows:
prefs = {'download.default_directory': '.\\x\\x\\'}

chrome_options.add_argument("--headless=new")
chrome_options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(options=chrome_options)

It’s strange how it worked fine without the trailing slash previously. Thanks to this older post

@Anilkumar-Shrestha there is no --headless=old. as of right now, it is either --headless=new or --headless

@sokol1412 - Do you know the bug id for Chrome/Chromedriver so that I can follow it’s status?

They fix it. Use --headless=new instead --headless and use the entire path to the folder e.g. /Users/xxx/downloads/folder1

With chrome version 113.0.5672.64 , issue with download file is working fine with chromeOptions.addArguments("--headless=old") .

I have chromedriver 111.0.5563.64 on my ubuntu docker image and same as @easytester21, I can confirm that issue is still present

I can confirm headless=new fixes codeception based download tests using anasess/setup-chromedriver

Same problem here , our tests that checks file downloads stopped working (still working fine on 109).

Did not test it fully , but it seems it works fine on 110 when not using headless mode , when using headless mode it always faill since it does not find the downloaded file.