How to run GUI tests on a jenkins windows slave without remote desktop connection? How to run GUI tests on a jenkins windows slave without remote desktop connection? jenkins jenkins

How to run GUI tests on a jenkins windows slave without remote desktop connection?


Your slave machines have to be at a desktop before the test can runproperly. We had the same problem.

Solution was to have the test machine start up and auto-logon to thedesktop. To ensure that the test would ONLY start after the desktopwas available, we added a scheduled task, set to run at user login,that would launch the Jenkins slave via Java Web Start. That way,Jenkins would only see the slave once the desktop was running. Afterthat, everything worked fine.

This is the winning answer to the question you linked to and it is very clear on what to do. The whole setup is outside of Jenkins. Jason Swager discribed on how he automated a user logging into a windows desktop machine and then starting the Jenkins slave in the user session.

And now Step by step:

1. make sure you have a GUI evailable

Solution was to have the test machine start up and auto-logon to the desktop

Configure a standard Windows desktop to login a specific user automatically when windows start. This way nobody needs to physically log into the desktop. (see How to turn on automatic logon in Windows 7)

2. start Jenkins slave

You need to start the Jenkins slave within this user setting. Otherwise, the Jenkins slave won't have access to the Windows UI components (or in other words can not interact with the desktop).

To ensure that the test would ONLY start after the desktopwas available, we added a scheduled task, set to run at user login,that would launch the Jenkins slave via Java Web Start.

So you have to create a scheduled task and configure it to start your Jenkins client using Java Web Start.

3. use it

That way, Jenkins would only see the slave once the desktop was running. Afterthat, everything worked fine.

When the slave is online, you can use it to run your UI tests.


To solve it, set Windows Auto-Logon as I explain here:https://serverfault.com/questions/269832/windows-server-2008-automatic-user-logon-on-power-on/606130#606130

Then create a startup batch for Jenkins slave (place it in Jenkins directory), which will launch it's console on desktop, and will allow GUI jobs to run:

java -jar slave.jar -jnlpUrl http://{Your Jenkins Server}:8080/computer/{Your Jenkins Node}/slave-agent.jnlp

(slave.jar can be downloaded from http://{Your Jenkins Server}:8080/jnlpJars/slave.jar)

EDIT :If you're getting black screenshots (when using Selenium for example), create a batch file that disconnects Remote Desktop, instead of closing the RDP session with the regular X button:

%windir%\system32\tscon.exe %SESSIONNAME% /dest:console


The following thing did the trick for me:

In Jenkins execute windows shell command:

  • cmdkey /generic:TERMSRV/<servername> /user:<username> /pass:<password>
  • mstsc /v:<servername> /w:<width> /h:<height>
  • cd <path to your pom.xml>
  • <maven command>(e.g. mvn test -Dfiles_to_run=groupLaunch.xml
  • cmdkey /delete:TERMSRV/<servername>

It creates real mstsc session (Win-to-Win) with specified width and height in your virtual mstsc session (Jenkins-to-Win) powered by Jenkins.