Reputation: 29
I'm trying to get my selenium tests running in Jenkins, but facing below issue. Tests run just fine in on my local computer when run using maven test or intellij.
Firefox 39 x64
Selenium 2.46.0
SeleniumHQ plugin (autoupdating, so should be latest version)
According to this, Xvfb server should be running
Xvfb starting$ Xvfb :1 -screen 0 1024x758x16 -fbdir /data/jenkins/xvfb-64-6044594236651529452.fbdir
Where is the problem? I can't figure it out after 2 days of searching internet and trying just about everything I've found.
Source:
public void setUp() throws Exception {
String Xport = System.getProperty("lmportal.xvfb.id", ":1");
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.setEnvironmentProperty("DISPLAY", Xport);
driver = new FirefoxDriver(firefoxBinary, null);
baseUrl = BASE_URL;
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
Error:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
1436973591335 DeferredSave.extensions.json DEBUG Save changes
1436973591336 addons.xpi DEBUG Updating XPIState for {"id":"[email protected]","syncGUID":"NERSGr4g-th8","location":"app-profile","version":"2.46.0","type":"extension","internalName":null,"updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Firefox WebDriver","description":"WebDriver implementation for Firefox","creator":"Simon Stewart","homepageURL":null},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"/tmp/anonymous134216584359310857webdriver-profile/extensions/[email protected]","installDate":1436973590000,"updateDate":1436973590000,"applyBackgroundUpdates":1,"bootstrap":false,"size":8440790,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":true,"hasBinaryComponents":true,"strictCompatibility":false,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"3.0","maxVersion":"66.*"}],"targetPlatforms":[{"os":"Darwin","abi":null},{"os":"SunOS","abi":null},{"os":"FreeBSD","abi":null},{"os":"OpenBSD","abi":null},{"os":"WINNT","abi":"x86-msvc"},{"os":"Linux","abi":null}],"multiprocessCompatible":false}
1436973591336 addons.xpi DEBUG getModTime: Recursive scan of [email protected]
1436973591338 addons.xpi DEBUG New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
1436973591340 addons.xpi-utils DEBUG Make addon app-global:{972ce4c6-7e08-4474-a285-3208198ce6fd} visible
1436973591340 DeferredSave.extensions.json DEBUG Save changes
1436973591340 DeferredSave.extensions.json DEBUG Save changes
1436973591340 addons.xpi DEBUG Updating XPIState for {"id":"{972ce4c6-7e08-4474-a285-3208198ce6fd}","syncGUID":"oj50TlNJya_g","location":"app-global","version":"39.0","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"/data/jenkins/tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/Firefox/firefox/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}","installDate":1435710843000,"updateDate":1435710843000,"applyBackgroundUpdates":1,"skinnable":true,"size":3169,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"39.0","maxVersion":"39.0"}],"targetPlatforms":[]}
1436973591340 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1436973591341 addons.xpi DEBUG Updating database with changes to installed add-ons
1436973591341 addons.xpi-utils DEBUG Updating add-on states
1436973591341 addons.xpi-utils DEBUG Writing add-ons list
1436973591345 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1436973591346 addons.manager DEBUG Provider finished startup: XPIProvider
1436973591346 addons.manager DEBUG Starting provider: LightweightThemeManager
1436973591346 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1436973591346 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1436973591346 addons.manager DEBUG Starting provider: GMPProvider
1436973591350 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1436973591351 addons.manager DEBUG Provider finished startup: GMPProvider
1436973591351 addons.manager DEBUG Starting provider: PluginProvider
1436973591351 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1436973591351 addons.manager DEBUG Provider finished startup: PluginProvider
1436973591352 addons.manager DEBUG Completed startup sequence
1436973591586 DeferredSave.extensions.json DEBUG Starting timer
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:120)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:275)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:220)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:215)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at cz.bsc.g6.mbs.pda.selenium.ide.Base.setUp(Base.java:52)
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:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102)
at org.apache.maven.surefire.Surefire.run(Surefire.java:180)
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:606)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
Upvotes: 1
Views: 1075
Reputation: 47
Are you setting the DISPLAY environment variable? This will need to be set in order for the tests to be executed in headless mode.
We use the Xvnc Jenkins plugin to assign the variable a random number in the job setup:
https://wiki.jenkins-ci.org/display/JENKINS/Xvnc+Plugin
Here's also a really useful guide to getting headless tests up and running using Jenkins:
Upvotes: 0