<ol>
<li><p>Following command line if you plan to run the same application in both a headless and a traditional environment: <a href="http://www.oracle.com/technetwork/articles/javase/headless-136834.html" rel="nofollow noreferrer">more details</a></p>

<p><code>java -Djava.awt.headless=true</code></p></li>
<li><p>You can add environment variable in Jenkins configurations
Manage Jenkins -> Configure System -> Global Properties -> Environment Variables section As: 
Name :  DISPLAY
Value:   0</p></li>
<li><p>Installing Jenkins master as a Windows service. This will run browser in other users account to get rid from this do following things:</p>

<p>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.</p>

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

<p>if still your problem persist go through following threads
<a href="https://github.com/DevExpress/testcafe/issues/1673" rel="nofollow noreferrer">1. for as service</a>,  </p></li>
</ol>

<p><a href="https://stackoverflow.com/questions/9618774/jenkins-selenium-gui-tests-are-not-visible-on-windows">2.  for general queries</a></p>

CC BY-SA 4.0
2018-09-18T04:47:35.980Z
thanks for the time. I have to  use `Jenkins master as a Windows service` so i can't disable it
NarendraR
CC BY-SA 4.0
2018-09-18T07:06:52.280Z
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
CC BY-SA 4.0
2018-09-18T07:07:25.840Z
added 2 thread in answer please refer them
Dev
CC BY-SA 4.0
2018-09-21T07:21:25.877Z
Dev, i have tried both solution but not working. i have updated my question as well
NarendraR
CC BY-SA 4.0
2018-09-24T11:12:33.950Z
You can use a [Jenkins plugin of a headless X server](https://wiki.jenkins.io/display/JENKINS/Xvfb+Plugin) to run your tests on an installed browser.
Dev
CC BY-SA 4.0
2020-05-27T08:04:09.947Z
@Dev The Xvfb plugin that you suggested, does it support on the Windows machine? Xvfb as a whole is only for Linux as far as I know.
Sid
CC BY-SA 4.0
2020-05-27T11:20:31.557Z
@Sid you are right, since all other solutions not worked. so as last option I suggested that, Not sure if that supports only linux.
Dev
CC BY-SA 4.0
2018-09-17T15:42:42.033Z
2018-09-18T07:09:29.883Z
2018-09-18T07:09:29.883Z
Dev
<p>Although it's too late to answer on this thread but it might help someone going forward.</p>

<p>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.</p>

<p>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.</p>

<ol>
<li>While service instance is running, install <a href="https://plugins.jenkins.io/thinBackup/" rel="nofollow noreferrer">ThinBackup</a> plugin, do the required settings and take the backup of Jenkins jobs, plugins, user data, configuration, etc.</li>
<li>Safely stop the Jenkins service instance using the URL - [jenkins-url]/exit (e.g. <a href="http://localhost:8080/exit" rel="nofollow noreferrer">http://localhost:8080/exit</a>).</li>
<li>Launch terminal, navigate to Jenkins installation directory and run the command: <code>java -jar jenkins.war</code> and let the server start.</li>
<li>Use the same url as earlier, do the initial configuration as per recommended plugins, login by creating new credentials.</li>
<li>Install <a href="https://plugins.jenkins.io/thinBackup/" rel="nofollow noreferrer">ThinBackup</a> plugin on the standalone instance and restore the backup. This will take few minutes to complete.</li>
</ol>

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

<hr>

<p><strong>Note:</strong> 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 <a href="https://support.microsoft.com/en-us/help/4558286/windows-10-add-an-app-to-run-automatically-at-startup" rel="nofollow noreferrer">here</a>.</p>

CC BY-SA 4.0
2020-05-27T11:38:24.207Z
2020-05-27T11:38:24.207Z
Sid
<p>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.</p>

<p>I've tried below solution :</p>

<ol>
<li><p>Checking jenkins service option to <strong><code>Allow service to interact with desktop</code></strong></p>

<p><a href="https://i.sstatic.net/O8bQ1.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/O8bQ1.png" alt="enter image description here"></a></p></li>
<li><p>Setting <strong><code>NoInteractiveServices</code></strong> flag to <code>0</code> in Registry </p>

<p><a href="https://i.sstatic.net/FTHbD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/FTHbD.png" alt="enter image description here"></a></p></li>
</ol>

<p>But nothing seem to work.</p>

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

<p>Any idea why this is happening ?</p>

<jenkins><continuous-integration><maven><java><selenium>
Jenkins executes Selenium test in headless mode while use `Jenkins as Service`
NarendraR
# Jenkins executes Selenium test in headless mode while use `Jenkins as Service`

(Asked by: username_0 on 2018-09-13)

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](https://i.sstatic.net/O8bQ1.png)](https://i.sstatic.net/O8bQ1.png)
2. Setting **`NoInteractiveServices`** flag to `0` in Registry

   [![enter image description here](https://i.sstatic.net/FTHbD.png)](https://i.sstatic.net/FTHbD.png)

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 ?

**Tags:** jenkins, continuous-integration, maven, java, selenium


---

## 2 answers

### Answer by username_1 on 2018-09-17. Score: 1

1. Following command line if you plan to run the same application in both a headless and a traditional environment: [more details](http://www.oracle.com/technetwork/articles/javase/headless-136834.html)

   `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](https://github.com/username_1Express/testcafe/issues/1673),

[2. for general queries](https://stackoverflow.com/questions/9618774/jenkins-selenium-gui-tests-are-not-visible-on-windows)

> **Comments:**
> **username_0**: thanks for the time. I have to  use `Jenkins master as a Windows service` so i can't disable it  
> **username_1**: 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.  
> **username_1**: added 2 thread in answer please refer them  
> **username_0**: username_1, i have tried both solution but not working. i have updated my question as well  
> **username_1**: You can use a [Jenkins plugin of a headless X server](https://wiki.jenkins.io/display/JENKINS/Xvfb+Plugin) to run your tests on an installed browser.  
> **username_2**: @username_1 The Xvfb plugin that you suggested, does it support on the Windows machine? Xvfb as a whole is only for Linux as far as I know.  
> **username_1**: @username_2 you are right, since all other solutions not worked. so as last option I suggested that, Not sure if that supports only linux.  

---

### Answer by username_2 on 2020-05-27. Score: 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 username_1 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](https://plugins.jenkins.io/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](https://plugins.jenkins.io/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](https://support.microsoft.com/en-us/help/4558286/windows-10-add-an-app-to-run-automatically-at-startup).


---

