I'm having trouble running some Selenium tests on a Jenkins agent. To be specific, the display resolution that is used to run the tests is too small, causing some of the tests to fail.
To check the display resolution, we log the display height and width to the console, using:
driver.manage().window().maximize();
System.out.println("Window height: " + driver.manage().window().getSize().getHeight());
System.out.println("Window width: " + driver.manage().window().getSize().getWidth());
This returns:
Window height: 784
Window width: 1040
which seems like a very strange resolution to me. The desired resolution is 1920 x 1080.
The server that is used as a agent is a virtual machine (Windows Server 2012 R2). The Jenkins agent is Connected via JNLP agent. The agent has the service running with Log On As "Local System" with the "Allow service to interact with desktop" option enabled.
So far we've tried a number of things like:
- Connecting to agent VM using RDP and disconnecting to leave session open with desired display resolution
- Using powershell to set the display resolution
- Setting the default display resolution in the VM configuration
- Setting the window dimensions using Selenium
- And more...
All of these didn't resolve the issues. Suggestions are very welcome!
driver.manage().window().setSize(new Dimension(1920, 1080))
– Beast