1

I have recently installed the Jenkins on Windows 10 Machine (Jenkins as Service) and configured one Maven Project (Selenium project which open chrome browser and executes some testcase). If i build the same, all my testcase gets execute in Chrome headless mode instead of opening actual browser.

I've tried below solution :

  1. Checking jenkins service option to Allow service to interact with desktop

    enter image description here

  2. Setting NoInteractiveServices flag to 0 in Registry

    enter image description here

But nothing seem to work.

while i use Jenkins by executing Jenkins.war file it runs the testcase as expected (non-headless) but not Jenkins as Service.

Any idea why this is happening ?

1
  1. Following command line if you plan to run the same application in both a headless and a traditional environment: more details

    java -Djava.awt.headless=true

  2. You can add environment variable in Jenkins configurations Manage Jenkins -> Configure System -> Global Properties -> Environment Variables section As: Name : DISPLAY Value: 0

  3. Installing Jenkins master as a Windows service. This will run browser in other users account to get rid from this do following things:

    3.1 Go to your services and stop Jenkins service. To see all your services run services.msc, from there find Jenkins service and disable\stop it.

    3.2 Go to jenkins home directory(C:\Program Files(x86)\Jenkins) and start cmd with administrator mode and hit java -jar jenkins.war

    if still your problem persist go through following threads 1. for as service,

2. for general queries

7
  • thanks for the time. I have to use Jenkins master as a Windows service so i can't disable it – NarendraR Sep 18 '18 at 4:47
  • You need to set 'Allow service to interact with desktop' in the service properties: SeleniumHQ/selenium#3349 and on Windows 10 you have to toggle the NoInteractiveServices registry key, or try to start it as a regular Windows CLI process from the terminal or a batch file. – Dev Sep 18 '18 at 7:06
  • added 2 thread in answer please refer them – Dev Sep 18 '18 at 7:07
  • Dev, i have tried both solution but not working. i have updated my question as well – NarendraR Sep 21 '18 at 7:21
  • You can use a Jenkins plugin of a headless X server to run your tests on an installed browser. – Dev Sep 24 '18 at 11:12
0

Although it's too late to answer on this thread but it might help someone going forward.

Only solution worked for me is to switch Jenkins from service to standalone. Unfortunately other solutions didn't work for me may be because latest version of Windows 10 doesn't at all allow running GUI apps from services. However, information given by Dev was very useful in understanding why I was facing the problem.

But while switching Jenkins from service to standalone, you'll have to reconfigure the server completely. So to avoid that I've detailed the steps to backup, safe exit (service), startup (standalone) and restore.

  1. While service instance is running, install ThinBackup plugin, do the required settings and take the backup of Jenkins jobs, plugins, user data, configuration, etc.
  2. Safely stop the Jenkins service instance using the URL - [jenkins-url]/exit (e.g. http://localhost:8080/exit).
  3. Launch terminal, navigate to Jenkins installation directory and run the command: java -jar jenkins.war and let the server start.
  4. Use the same url as earlier, do the initial configuration as per recommended plugins, login by creating new credentials.
  5. Install ThinBackup plugin on the standalone instance and restore the backup. This will take few minutes to complete.

Now you'll be able to run the tests by actually launching the browser as well as use Jenkins server as configured earlier.


Note: The standalone instance won't have the auto startup of the server as was the case with service instance. In order to achieve that create a batch file having Jenkins startup command as above and follow the steps described here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.