Not able to maximize Chrome Window in headless mode

137 views
Skip to first unread message

Kev Martin

unread,
Jun 12, 2025, 7:29:06 PMJun 12
to Selenium Users

Up until last week this has worked a charm in headless mode with an Azure pipelime and also local with this setup code

We are  using Visual Studio/C#/Selenium 4.33

We use ChromiumDriver for our Windows Desktop tests

protected static ChromiumDriver? Driver { get; set; } = null;            

Mon,Web,Fri this kicks off Chrome, Tues & Thurs MS Edge

            var options = new EdgeOptions
            {
                PageLoadStrategy = PageLoadStrategy.Normal
            };
            options.AddArgument("enable-automation");
            options.AddArgument("disable-dev-shm-usage");
            options.AddArgument("ignore-certificate-errors");
            options.AddArgument("ignore-ssl-errors");
            options.AddArgument("disable-popup-blocking");
            options.AddArgument("window-size=1920,1080");
            options.AddUserProfilePreference("download.default_directory", DownloadPath);
            if (!Debugger.IsAttached)
                options.AddArgument("headless");
            options.AddArgument("disable-gpu");
            var service = EdgeDriverService.CreateDefaultService();
            Driver = new EdgeDriver(service, options, TimeSpan.FromSeconds(MaxWait));

            SetTimeOuts(MaxWait);
            Driver.Manage().Cookies.DeleteAllCookies();
            Driver.Manage().Window.Maximize();
            Driver.ExecuteCdpCommand(
                "Emulation.setTimezoneOverride",
                new Dictionary<string, object>
                {
                    ["timezoneId"] = "Europe/London"
                });


So early last week we updated Selenium.WebDriver.ChromeDriver from 135 to 136 and things have fallen apart with our desktop tests. We also have a set of tests using Playwright, these are working fine.

I have grabbed a screenshot on our app in code while running in headless mode and these confirm the app have started running in tablet mode since the webdriver update.
 
test2.png
 
The screensize appears to be 784 by 445

In our app this means that certainm buttons and links will not be available and the menu options are hidden until the mobile button is pressed (see image). This has caused the fails.

My question is why has this change, the settings above have work for just over 3 years now, whta has change in ChromeDriver and how do I force full screen desktop mode again

I have added
options.AddArgument("user-agent=Chrome/136.0.0.0");
But no affect

Kev

Nortier David

unread,
Jun 16, 2025, 3:09:45 AMJun 16
to seleniu...@googlegroups.com

Hello

µ

Same problem recently, with Chrome :-(

 

I'm also headless, under DevOps.

I added chromeOptions.AddArgument("--window-size=1920,1080");

and the problem disappeared

(except in one test apparently this morning...)

 

David

 

 

De : seleniu...@googlegroups.com <seleniu...@googlegroups.com> De la part de Kev Martin
Envoyé : lundi 9 juin 2025 13:03
À : Selenium Users <seleniu...@googlegroups.com>
Objet : [selenium-users] Not able to maximize Chrome Window in headless mode

 

ATTENTION : cet e-mail provient d'une personne externe. Vérifiez toujours l’expéditeur avant d’ouvrir les pièces jointes ou de cliquer sur les liens.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/a4663dd7-5b4b-4fb5-9c90-1b4a5d7924d2n%40googlegroups.com.


====== DISCLAIMER ======

https://www.cph.be/maildisclaimer

Reply all
Reply to author
Forward
0 new messages