I'm trying to run UI automation with a Jenkins job that runs on a windows VM as a jenkins slave, as a part of a CI pipeline. I have a problem that the screen resolution is set to be very low (1024, 768) how can I change the default resolution, so that when jenkins opens a new connection it will be with a larger resolution?
-
1I am also having the same trouble, though my webdriver window is resolution 1040x784 when fullscreened in Jenkins (1936x1056 when running on my desktop, same machine) – Steve Aug 14 '14 at 15:29
5 Answers
If your UI automation involves running Chrome, you might find it helpful to run Headless Chrome. That way, the screen resolution of the slave won't matter as you can specify the resolution you want to be used.
I was able to achieve this with these Chrome startup arguments running on a Windows Server Jenkins slave:
--headless --window-size=1920,1080
In my case, with Nightwatch, this is a snippet of the nightwatch.json file:
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": ["--window-size=1920,1080", "--headless"]
},
// ...

- 692
- 10
- 16
Do you have your webapp container started as a local service (tomcat or jenkins slave?). The point is that windows services cannot have GUI and it's even a miracle, that WebDriver somehow manages to open a 1024,768 window :) Start your webapp container as a console application with a normal user.

- 744
- 4
- 27
I've got the same issue while trying to run UI tests on Jenkins
Problem: By default jenkins ran as windows service and have not access to run tests on desktop.
So fix:
- run >> services.msc >> stop the system service Jenkins.exe
- right click on Jenkins.exe >> properties >> startup type - Manual >> save
- create an executable file (.bat, .exe, ...) save it somewhere and type there:
java -jar "C:\path\to\Jenkins\jenkins.war" --httpPort=8081
- add shortcut of this executable file to windows autorun directory
It will run Jenkins on Desktop (non windows service) what allows run your UI tests there

- 113
- 9
Theoretically, running powerscript command as the build step:
set-displayresolution 1920 1080 -Force
should do it, but I have some problems with right now...
What has definitely worked: connect to your VM with RDP using desired resolution, then disconnect. The tests will run in the last resolution used.

- 1,548
- 3
- 15
- 34
I am facing the same issue. And found two different resolutions.
If your requirement is to see the chrome browser then open the command prompt and execute the below command
Java -jar jenkins.war
If your goal is just to change the resolution then add the below options and you can see the configure resolution(in the below example resolution is 1920,1080):-
ChromeOptions options = new ChromeOptions(); options.addArguments("enable-automation"); options.addArguments("--headless"); options.addArguments("--window-size=1920,1080"); options.addArguments("--no-sandbox"); options.addArguments("--disable-extensions"); options.addArguments("--dns-prefetch-disable"); options.addArguments("--disable-gpu");