Skip to content

[🐛 Bug]: Headless Chrome - New Windows Open in Incorrect (Compressed) Size #16075

@SuravinS

Description

@SuravinS

Description

When using headless Chrome mode via Selenium, any new windows or tabs opened during test execution (e.g., via window.open() or by clicking a link with target="_blank") are opened in a compressed or smaller than expected size, even though the window-size argument is passed correctly in Chrome options.

Reproducible Code

Environment:

Selenium Version: [4.31.0]

Chrome Version: [138.0.7204.158]

Chromedriver Version: [138.0.7204.157]

OS: [Windows 11]

Language: C#

Execution Mode: Headless


`else if (browser.Equals("hchrome", StringComparison.OrdinalIgnoreCase))
                {
                    IsHeadless = true;  // headless
                    ChromeOptions options = new ChromeOptions();
                    options.AddArgument("--headless");
                    if (isIncognito) options.AddArgument("--incognito");
                    options.AddArgument("--disable-extensions");
                    options.AddArgument("--disable-gpu");
                    options.AddArgument("--no-sandbox");
                    options.AddArgument("window-size=1920,1080");
                    options.AddArgument("disable-features=DownloadBubble,DownloadBubbleV2");
                    options.AddUserProfilePreference("download.default_directory", downloadDir);
                    options.AddUserProfilePreference("disable-popup-blocking", "true");
                    options.AddUserProfilePreference("download.prompt_for_download", false);
                    options.AddUserProfilePreference("profile.default_content_setting_values.automatic_downloads", 1);
                    options.AddUserProfilePreference("credentials_enable_service", false);
                    options.AddUserProfilePreference("profile.password_manager_enabled", false);

                    new DriverManager().SetUpDriver(new ChromeConfig());
                    Drivers.Value = new ChromeDriver(options);
                }`





ℹ️ Last known working version: 4.16.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions