Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default window size when running Selenium tests over Azure Pipelines?

I am running headless Selenium tests on Azure DevOps (formerly VSTS) with ChromeDriver—see the article here https://learn.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?

like image 238
devlord Avatar asked Oct 20 '25 01:10

devlord


1 Answers

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

like image 139
bunkerdive Avatar answered Oct 21 '25 17:10

bunkerdive



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!