2
votes

I am running headless Selenium tests on Azure DevOps (formerly VSTS) with ChromeDriver—see the article here https://docs.microsoft.com/en-us/azure/devops/pipelines/test/continuous-test-selenium?view=azure-devops on how to set this up.

I have an issue where tests fail due to an element not being visible and I suspect it's because of the media queries in CSS which force a different layout than expected. (I am expecting to test the desktop rendering of the site.)

What is the default window size for Selenium when running on a VSTS build?

1
it's been a while, but last time I tried it was 0x0px. Making sure your tests set the resolution and the window size as part of your test initialization is important :). – jessehouwing

1 Answers

1
votes

As discussed in a previous comment, you can set window-size and start chrome maximized using ChromeOptions, such as (in C#):

// use headless chrome
var options = new ChromeOptions();
options.AddArguments(new List<string>()
                    {
                        "--headless",
                        "--disable-gpu",
                        "--no-first-run",
                        "--no-default-browser-check",
                        "--ignore-certificate-errors",
                        "--no-sandbox",
                        "--window-size=1280,1920",
                        "--start-maximized",
                        "--disable-dev-shm-usage",
                    });
WebDriver = new ChromeDriver(".", options);

Note: I am use Selenium.WebDriver.ChromeDriver v75.0.3770.140, and running on an Azure DevOps Services Windows 2019 with VS2019 agent, which is currently configured with Chrome v75.0.3770.100