SeleniumHQ/selenium

[🐛 Bug]: Headless Mode Results in White Screen in Selenium [C#]

serizava01 opened this issue · 8 comments

What happened?

I have encountered an issue while using Selenium with the headless argument. When running the browser in headless mode, the page renders as a blank (white) screen, even though the site works fine when running in non-headless mode. The page appears to load successfully (based on network logs and console messages), but no content is visible.

Steps to Reproduce:

Set up a Selenium WebDriver (Chrome) with the headless option enabled.
Navigate to a webpage that renders correctly in non-headless mode.
Observe that the content does not display, and the screen remains white in headless mode.
Expected Behavior: The page should render as it does in non-headless mode, displaying the full content.

Actual Behavior: The page appears as a blank white screen

Thank you!
สกรีนช็อต 2024-09-27 164412

How can we reproduce the issue?

ChromeOptions options = new ChromeOptions();
            if (!checkBox1.Checked)
            {
                options.AddArgument("--headless");  
                options.AddArgument("window-size=1920x1080");
               
               
            }
            ChromeDriver driver = new ChromeDriver(options);
            driver.Navigate().GoToUrl("https://www.google.com/");

Relevant log output

Starting ChromeDriver 129.0.6668.70 (df87d5cf12b1397be7495a04cab2db6239b227a8-refs/branch-heads/6668@{#1420}) on port 58239
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully on port 58239.

DevTools listening on ws://127.0.0.1:58242/devtools/browser/f686c0cd-e61e-46c1-8192-d5882dbf1477

Operating System

11 Pro

Selenium version

4.25.0

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

129.0.6668.70

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

Latest version comes with selenium

Are you using Selenium Grid?

No

@serizava01, 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!

Hi, @serizava01.
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.

change
options.AddArgument("--headless")
on
options.AddArgument("--headless=old")

Depending on the new headless mode, now you can use --headless=old, but Selenium should make it more compatible so that it detect when to use --headless or --headless=old. Because me myself I am not sure when to use these in a project I want to publish soon and it should be compatible.

I am confused of what versions of Selenium and Chrome the --headless or --headless=old should be used, also be sure that only the new headless mode will be used in upcoming updates of Chrome depending on that they say:
image_2024-10-08_220726349

Purpose of this

image

Thanks everyone I fixed it <3

Did you fix it by using "--headless=old" instead? @serizava01

Did you fix it by using "--headless=old" instead? @serizava01

Yes