0

I'm trying to run a test case on Jenkins with Selenium but I get a "Cannot open display" (I've tried it with both display ":1" and ":99").

Some info:

  • Selenium version 2.35.0
  • JDK 1.6.0_25
  • I'm running on a Debian environment
  • I have installed Xvfb
  • The DISPLAY is declared both in the code (see below) and in jenkins/configure Global properties (name = DISPLAY, value = :99 (or :1))

My POM:

<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>

    <groupId>org.squashtest.jenkins</groupId>
    <artifactId>my.squash.ta.project</artifactId>
    <packaging>pom</packaging>
    <version>1.0</version>

    <!-- Properties definition -->
    <properties>
        <!-- Squash-TA framework version used by the project -->
        <ta.framework.version>1.7.1-RELEASE</ta.framework.version>
        <!-- Log configuration file -->
        <logConfFile>src/log4j.properties</logConfFile>
    </properties>

    <build>
        <plugins>
            <!-- Configuration of the Squash TA framework used by the project -->
            <plugin>
                <groupId>org.squashtest.ta</groupId>
                <artifactId>squash-ta-maven-plugin</artifactId>
                <version>${ta.framework.version}</version>

                <dependencies>
                    <dependency>
                        <groupId>org.seleniumhq.selenium</groupId>
                        <artifactId>selenium-java</artifactId>
                        <version>2.35.0</version>
                    </dependency>  
                     <dependency>
                        <groupId>org.seleniumhq.selenium</groupId>
                        <artifactId>selenium-firefox-driver</artifactId>
                        <version>2.35.0</version>
                    </dependency>
                     <dependency>
                        <groupId>org.seleniumhq.selenium</groupId>
                        <artifactId>selenium-server</artifactId>
                        <version>2.35.0</version>
                     </dependency>  
                </dependencies>

                <!-- Under here is the Squash TA framework default configuration -->
                <configuration>

                    <!-- Uncomment the line below in order to the build finish in success even if a test failed -->
                    <!-- <alwaysSuccess>true</alwaysSuccess> -->

                    <!-- Define a log configuration file (at log4j format) to override the one defined internally -->
                    <!-- If the given file can't be found the engine switch to the internal configuration-->
                    <logConfiguration>${logConfFile}</logConfiguration>

                    <!-- Define exporters -->
                    <exporters>
                        <surefire>
                            <jenkinsAttachmentMode>${ta.jenkins.attachment.mode}</jenkinsAttachmentMode>
                        </surefire>
                        <html/>
                    </exporters>

                    <!-- Define configurers -->
                    <configurers>
                        <tmCallBack>
                            <endpointURL>${status.update.events.url}</endpointURL>
                            <executionExternalId>${squash.ta.external.id}</executionExternalId>
                            <jobName>${jobname}</jobName>
                            <hostName>${hostname}</hostName>
                            <endpointLoginConfFile>${squash.ta.conf.file}</endpointLoginConfFile>
                        </tmCallBack>
                    </configurers>
                </configuration>

                <!-- Bind the Squash TA "run" goal to the maven integration-test phase and reuse the default configuration -->
                <executions>
                    <execution>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <!-- Squash TA maven repository -->
    <repositories>
        <repository>
            <id>org.squashtest.ta.release</id>
            <name>squashtest test automation - releases</name>
            <url>http://repo.squashtest.org/maven2/releases</url>
        </repository>
    </repositories>

    <!-- Squash TA maven plugin repository -->
    <pluginRepositories>
        <pluginRepository>
            <id>org.squashtest.plugins.release</id>
            <name>squashtest.org</name>
            <url>http://repo.squashtest.org/maven2/releases</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>

</project>

My code:

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import java.io.File;
import org.openqa.selenium.support.ui.Select;

public class ConnexionInterfaceFortress {

String baseUrl = "http://foobar.com";
WebDriver driver = null;
StringBuffer verificationErrors = new StringBuffer();
boolean acceptNextAlert = true;
FirefoxBinary binary = new FirefoxBinary(new File("/usr/bin/firefox"));
FirefoxProfile profile = new FirefoxProfile();

  @Before
  public void setUp() throws Exception {
  }

  @Test
  public void testConnexion() throws Exception {
try{
        binary.setEnvironmentProperty("DISPLAY",System.getProperty("lmportal.xvfb.id",":99"));
        profile.setEnableNativeEvents(true);
        driver = new FirefoxDriver(binary, profile);
        } catch (Error e) {
            System.out.println("Creation du navigateur impossible");
        }
    driver.manage().window().maximize();      
    driver.get(baseUrl); 
 }

  @After
  public void tearDown() throws Exception {
    driver.quit();
    String verificationErrorString = verificationErrors.toString();
    if (!"".equals(verificationErrorString)) {
      fail(verificationErrorString);
    }
  }

  private boolean isElementPresent(By by) {
    try {
      driver.findElement(by);
      return true;
    } catch (NoSuchElementException e) {
      return false;
    }
  }

  private String closeAlertAndGetItsText() {
    try {
      Alert alert = driver.switchTo().alert();
      if (acceptNextAlert) {
        alert.accept();
      } else {
        alert.dismiss();
      }
      return alert.getText();
    } finally {
      acceptNextAlert = true;
    }
  }
}

My full log:

Started by user tmserver
Building in workspace /usr/local/bin/squashta/execution_home/jobs/Connexion 2/workspace
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@gitlab.rvip.fr:qa/QAJenkinsTest.git # timeout=10
Fetching upstream changes from git@gitlab.rvip.fr:qa/QAJenkinsTest.git
 > git --version # timeout=10
 > git -c core.askpass=true fetch --tags --progress git@gitlab.rvip.fr:qa/QAJenkinsTest.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 05b328fa1a5b07a9c225eee58683e6d19ef98fa1 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 05b328fa1a5b07a9c225eee58683e6d19ef98fa1
 > git rev-list 00124836ba6caebc7e9ffbd234b2fa01488c10b9 # timeout=10
provisoning config files...
copy managed file [conf.properties] to file:/usr/local/bin/squashta/execution_home/taLinkConf.properties
Copying file to testsuite.json
Parsing POMs
using global settings config with name TaGlobalSettings
Replacing all maven server entries not found in credentials list is null
[workspace] $ /usr/local/bin/squashta/openjdk1.6.0_25-unix-i586/bin/java -Xms512m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=512m -cp /usr/local/bin/squashta/execution_home/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.4.jar:/usr/local/bin/squashta/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /usr/local/bin/squashta/apache-maven-3.0.4 /usr/local/bin/squashta/apache-tomcat-7.0.54/webapps/jenkins/WEB-INF/lib/remoting-2.33.jar /usr/local/bin/squashta/execution_home/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.4.jar /usr/local/bin/squashta/execution_home/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.4.jar 56944
<===[JENKINS REMOTING CAPACITY]===>channel started
using global settings config with name TaGlobalSettings
Replacing all maven server entries not found in credentials list is null
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven:  -B -f /usr/local/bin/squashta/execution_home/jobs/Connexion 2/workspace/pom.xml -gs /usr/local/bin/squashta/apache-tomcat-7.0.54/temp/global-settings7531672306724044985.xml -Dta.test.suite=ConnexionInterfaceFortress.ta -Dstatus.update.events.url=file://dev/null -Dsquash.ta.external.id= -Djobname=Connexion 2 -Dhostname=AWS-RND-TEST-PR -Dsquash.ta.conf.file=/usr/local/bin/squashta/execution_home/taLinkConf.properties -Dta.tmcallback.reportbaseurl=http://squashta.rvip.fr:9080/jenkins/job -Dta.tmcallback.jobexecutionid=46 -Dta.tmcallback.reportname=Squash_TA_HTML_Report -Dta.delete.json.file=true org.squashtest.ta::squash-ta-maven-plugin::run
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building my.squash.ta.project 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- squash-ta-maven-plugin:1.7.1-RELEASE:run (default-cli) @ my.squash.ta.project ---
[INFO] Loading external logging configuration: /usr/local/bin/squashta/execution_home/jobs/Connexion 2/workspace/src/log4j.properties
[INFO] Squash TA : compiling tests...
[INFO] Squash TA : initializing context...
[INFO] org.squashtest.ta.backbone.init.ComponentPackagesEnumerator - Listing sqhashTA engine component packages
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.enginecore
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.commons-component
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.filechecker
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.sahi
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.selenium
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.local.process
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.soapui
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.ftp
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.db
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.ssh
[WARN] org.squashtest.ta.link.SquashTMCallbackEventConfigurer - The endpoint URL is set to its default value: "file://dev/null", so the call back is not activated
[INFO] Squash TA : testing...
[INFO] org.squashtest.ta.backbone.engine.impl.EcosystemRunnerImpl - Beginning execution of ecosystem tests
[INFO] org.squashtest.ta.backbone.engine.impl.TestRunnerImpl - Beginning execution of test setup.ta
[INFO] org.squashtest.ta.backbone.engine.impl.TestRunnerImpl - Beginning execution of test ConnexionInterfaceFortress.ta
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: cannot open display: :99
Error: cannot open display: :99

    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:106)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:251)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:195)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:190)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
    at ConnexionInterfaceFortress.testConnexion(ConnexionInterfaceFortress.java:33)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:24)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:117)
    at org.squashtest.ta.plugin.selenium.library.StandardJUnitExecutor.apply(StandardJUnitExecutor.java:74)
    at org.squashtest.ta.plugin.selenium.commands.ExecuteJavaSeleniumTwoCommand.apply(ExecuteJavaSeleniumTwoCommand.java:80)
    at org.squashtest.ta.plugin.selenium.commands.ExecuteJavaSeleniumTwoCommand.apply(ExecuteJavaSeleniumTwoCommand.java:1)
    at org.squashtest.ta.backbone.engine.wrapper.CommandHandler.apply(CommandHandler.java:132)
    at org.squashtest.ta.backbone.engine.instructionrunner.DefaultExecuteCommandRunner.doRun(DefaultExecuteCommandRunner.java:79)
    at org.squashtest.ta.backbone.engine.instructionrunner.AbstractDefaultInstructionRunner.run(AbstractDefaultInstructionRunner.java:69)
    at org.squashtest.ta.backbone.engine.impl.TestRunnerImpl.runInstruction(TestRunnerImpl.java:190)
    at org.squashtest.ta.backbone.engine.impl.TestRunnerImpl.runInstructionList(TestRunnerImpl.java:139)
    at org.squashtest.ta.backbone.engine.impl.TestRunnerImpl.runMetaInstruction(TestRunnerImpl.java:162)
    at org.squashtest.ta.backbone.engine.impl.TestRunnerImpl.runInstructionList(TestRunnerImpl.java:137)
    at org.squashtest.ta.backbone.engine.impl.TestRunnerImpl.runPhase(TestRunnerImpl.java:127)
    at org.squashtest.ta.backbone.engine.impl.TestRunnerImpl.runTest(TestRunnerImpl.java:108)
    at org.squashtest.ta.backbone.engine.impl.EcosystemRunnerImpl.runAllTests(EcosystemRunnerImpl.java:185)
    at org.squashtest.ta.backbone.engine.impl.EcosystemRunnerImpl.run(EcosystemRunnerImpl.java:103)
    at org.squashtest.ta.backbone.engine.impl.SuiteRunnerImpl.execute(SuiteRunnerImpl.java:68)
    at org.squashtest.ta.backbone.engine.impl.EngineImpl.execute(EngineImpl.java:63)
    at org.squashtest.ta.maven.SquashTAMojo.executeImpl(SquashTAMojo.java:204)
    at org.squashtest.ta.maven.AbstractSquashTaMojo.execute(AbstractSquashTaMojo.java:209)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:117)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
    at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:178)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
    at hudson.remoting.UserRequest.perform(UserRequest.java:118)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:328)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
[ERROR] org.squashtest.ta.backbone.engine.impl.TestRunnerImpl - The execution failed in the TEST phase of the TA script 'ConnexionInterfaceFortress.ta' with the message: 'Selenium test failed. Following are the name of the tests that failed:
testConnexion(ConnexionInterfaceFortress)
testConnexion(ConnexionInterfaceFortress)
'.
[INFO] org.squashtest.ta.backbone.engine.impl.TestRunnerImpl - Beginning execution of test teardown.ta
[INFO] Exporting results
[INFO] Cleaning resources
[INFO] Squash TA : build complete.
[INFO] org.squashtest.ta.core.tools.io.TempFileUtils - All the files from /tmp/Squash_TA were properly deleted.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 53.303s
[INFO] Finished at: Thu Jan 07 11:08:27 CET 2016
[INFO] Final Memory: 24M/490M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving disabled
Waiting for Jenkins to finish collecting data[ERROR] Failed to execute goal org.squashtest.ta:squash-ta-maven-plugin:1.7.1-RELEASE:run (default-cli) on project my.squash.ta.project: Build failure : there are tests failures
[ERROR] Test statistics : 1 test runs, 0 passed, 1 tests didn't pass
[ERROR] Tests failed / crashed :
[ERROR] -----------
[ERROR] tests:
[ERROR] ==> ConnexionInterfaceFortress.ta
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

channel stopped
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at BUILD level /usr/local/bin/squashta/execution_home/jobs/Connexion 2/workspace/target/squashTA/html-reports to /usr/local/bin/squashta/execution_home/jobs/Connexion 2/builds/2016-01-07_11-07-26/htmlreports/Squash_TA_HTML_Report
[htmlpublisher] Archiving at PROJECT level /usr/local/bin/squashta/execution_home/jobs/Connexion 2/workspace/target/squashTA/test-tree to /usr/local/bin/squashta/execution_home/jobs/Connexion 2/htmlreports/Test_list
Finished: FAILURE

Does anyone know what am I doing wrong?

Thank you in advance.

2 Answers2

1

First, fix your Firefox version and selenium version match by testing it locally. If you are running job through Jenkins and in the logs you are getting the error:

Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: Error: cannot open display: :0

To resolve, look below steps:

  1. Firefox will launch only if you have Xvfb running, Remember Xvfb performs all graphical operations in virtual memory without showing any screen output. Run Xvfb as below. example: Xvfb :15 -screen 0 1024x768x16 so check this first, this check you could include into job by adding ps -ef into pre-steps (shell execution) of job.

  2. Even if you would have define explicitly the DISPLAY value but you have still error then the best method is to inject as a environmental value in Jenkin job itself. Under Build environment >> Inject env variables >> Properties content >> DISPLAY=:15 (you could set Display according to you, same should be in xvfb running)

  3. Run your job, should have been fixed.

pfranza
  • 3,292
  • 2
  • 21
  • 34
0

It turns out the Jenkins user is only a service account and it has no access to any X server session, hence unable to open a browser to complete the test.

Unless you run it in headless mode with the help of the Xvfb plugin, or view the output through the virtual display given by the Xvnc plugin, it seems currently there is no better way to achieve selenium test in Jenkins build.

You may want to read more on an existing question here.

Community
  • 1
  • 1
Ruifeng Ma
  • 2,399
  • 1
  • 22
  • 40