SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
29.73k stars 8.02k forks source link

[🐛 Bug]: Python, Pytest - download.default_directory is not working when --headless=new #14150

Closed petrisorionel closed 1 week ago

petrisorionel commented 1 week ago

What happened?

When we set the --headless=new argument for Chrome options and download.default_directory prefs, download is not working, file is not downloaded in default directory.

prefs = {"download.default_directory": os.path.join(ROOT_DIR, DYNAMIC_FILES_DIR),
                 "savefile.default_directory": os.path.join(ROOT_DIR, DYNAMIC_FILES_DIR),
                 "download.prompt_for_download": False,
                 "download.directory_upgrade": True}
        options.add_experimental_option("prefs", prefs)`

options.add_argument("--headless=new")`

How can we reproduce the issue?

Every basic test with --headless=new argument for Chrome options.

Relevant log output

-

Operating System

Windows 10, Debian 11

Selenium version

selenium==4.21.0

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

google-chrome-stable 125.0.6422.112-1

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

google-chrome-stable 125.0.6422.112-1

Are you using Selenium Grid?

no

github-actions[bot] commented 1 week ago

@petrisorionel, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

github-actions[bot] commented 1 week ago

Hi, @petrisorionel. This issue has been determined to require fixes in ChromeDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an issue with the ChromeDriver team. Feel free to comment the issues that you raise back in this issue. Thank you.

petrisorionel commented 1 week ago

@diemol can you explain why with "--headless=old" is working?

diemol commented 1 week ago

You can find more information here https://developer.chrome.com/docs/chromium/new-headless

This is out of the scope of Selenium, it is how Chrome behaves.