35

When I run my selenium test (mvn test) from jenkins (windows) I see only the console output. I don't see the real browsers getting opened . How can I configure jenkins so that I can see the browsers running the test?

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
Rajesh
  • 773
  • 1
  • 9
  • 11
  • The browsers will open on the build server. Just want to check that you are logging into the build server and not seeing the browsers open from there. – Sachin Kainth Mar 08 '12 at 14:02

9 Answers9

30

I had the same problem, i got the solution after many attempts. This solution works ONLY on windows XP

If you are using jenkins as a windows service you need to do the following :

1) In windows service select the service of jenkins

Opening Service.msc view

2) Open properties window of the service -> Logon-> enable the checkbox "Allow service to interact with desktop"

Jenkins properties

After then you should reboot the service jenkins

Hope this help you :)

UPDATE:

Actually, I'm working on a an automation tool using Selenium on Windows 10, I've installed Jenkins ver. 2.207 as windows application (EXE file), it's running as windows service and ALL drivers (Chrome, FireFox, IE) are visible during test executions WITHOUT performing a mere configuration on the System or Jenkins

Shessuky
  • 1,846
  • 21
  • 24
29

I got the solution. I ran jenkins from command prompt as "java -jar jenkins.war" instead of the windows installer version. Now I can see my browser based tests being executed.

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
Rajesh
  • 773
  • 1
  • 9
  • 11
  • Thanks to this site for providing the solution http://forgetfulprogrammer.wordpress.com/tag/interact-with-desktop/ – Rajesh Mar 12 '12 at 13:45
  • The above answer is very much helpful for me. I also faced the same problem. Now solved by running jenkins as java -jar jenkins.war – Ripon Al Wasim Feb 26 '13 at 09:21
  • 2
    When I run jenkins this way "java -jar jenkins.war" my projects disapeared. This was a bit scary the first time. The projects come back when I run them as the service.... but I can't see the browser in action. Any ideas? – Patrick Cummins Dec 05 '13 at 06:17
  • @PatrickCummins you need to specify some other things such as the webroot dir ala `--webroot="C:\Program Files (x86)\Jenkins\war"` as well as the `JENKINS_HOME` environment variable prior to running the JAR, e.g. `$Env:JENKINS_HOME = "C:\Program Files (x86)\Jenkins"` – nebffa Dec 08 '16 at 00:25
  • This work for me too for a javafx/swing app!! But when i launch it from the browser the forked app doesn't have focus and test testrobot doesn't work ?? Have find a solution to this – user43968 Aug 09 '18 at 16:44
  • Here is code for a batch file (for a shortcut to the start folder) in order to launch Jenkins as a process, not a service: cmd /k "cd C:\Program Files\Jenkins && java -jar jenkins.war" – JohnP2 Dec 24 '21 at 23:31
8

If you are already doing what @Sachin suggests in a comment (i.e. looking at the machine where Jenkins actually runs) and still do not see the browsers, then your problem may be the following:

If you run Jenkins as a service in the background it won't open apps in the foreground. You may either try to run it not as a service in the foreground, or run it as a Local System account and check Allow the service to interact with desktop option. In the latter case you may get into permission problems, though.

Update: To make sure this answer is understood properly by others: Jenkins Windows 'native' installation is not really native. It's a wrapper around Java that runs it as a service.

malenkiy_scot
  • 16,415
  • 6
  • 64
  • 87
  • I tried what you suggested but it did not work out. Finally had to run jenkins as java -jar jenkins.war – Rajesh Mar 12 '12 at 13:44
  • When I said 'run it not as a service in the foreground' I actually meanu `java -jar jenkins.war` – malenkiy_scot Mar 12 '12 at 14:57
  • @rajesh You should set malenkiy_scot's answer as the accepted one because it is correct and was provided before you 'figured it out' yourself. – SHaKie Jun 08 '15 at 09:34
6

To interact with desktop GUI, you should launch slave agent via JNLP: https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds#Distributedbuilds-LaunchslaveagentviaJavaWebStart

After adding the node in Jenkins (configured as Java Web Start launch), just make a startup batch script on the node machine:

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)

See more answers here: How to run GUI tests on a jenkins windows slave without remote desktop connection?

Community
  • 1
  • 1
Noam Manos
  • 15,216
  • 3
  • 86
  • 85
  • Thanks, I just spend a day GUI tests to be visible on Windows and this solution worked! My tests had started failing when I ran Jenkins as a service, probably because of changes to the service's hidden desktop, for example, screen resolution changes (see @Shessuky's Windows 7 answer). – JaneGoodall Sep 01 '15 at 18:33
5

In the case of Windows 7 you should not install jenkins as windows application (because in this recent version, Microsoft decided to give services their own hidden desktop even you enable the functionality "interact with desktop" in jenkins service), you may have to deploy it from a war file as follows:

1) Download jenkins.war from Jenkins official site

2) Deploy it by the command prompt : java -jar {directoryOfJenkinsFile}/jenkins.war

3) Now you can access jenkins administration on http:// localhost:8080

Hope that helps you !

Shessuky
  • 1,846
  • 21
  • 24
1

this is an issue for Jenkins. on Windows it is possible to access logon user's session (screen) under system account. to make the UI testing visible, Jenkins needs to bypass UAC (user access control) at background. this solution works for me with my own service running as system account.

1

I also faced the same issue earlier in my local machine (Windows 10). My test was running perfectly from the NetBeans but when I moved to Jenkins it was only running in console mode. I was unable to view the UI.

So for that, you just need to make your local machine as a Jenkins slave by creating a new slave node in your Jenkins and select that node to execute the Jenkins job.

pablo casanovas
  • 128
  • 1
  • 2
  • 15
0

If jenkins installed by windows installer it is showing only Console out put only. To see browsers download jenkins.war file and run java -jar jenkins.war from command line. Go through this site: http://learnseleniumtesting.com/jenkins-and-continuous-test-execution/

Divya C
  • 11
  • 1
0

If you have the following situation,

  1. You are able to login to the remote machine
  2. You don't see the Jenkins agent window
  3. This slave machine is accessed by many users then try the following,

then try the following suggestion.

  • Login to slave machine
  • Go to Task manager
  • Users
  • Logout all the users
  • Then login again.

This worked for me.

Subash
  • 301
  • 3
  • 9