1

When I tried to run selenium test using Xvfb i am getting this below error

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host localhost.localdomain on port 7055 after 45000 ms. Firefox console output: Error: cannot open display: 1

at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:113)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:128)
at com.gtech.automation.uk.webdriver.WebDriverFactory.getWebDriver(WebDriverFactory.java:41)
at com.gtech.automation.uk.dashboard.DashboardImpl.getWebDriver(DashboardImpl.java:53)
at com.gtech.automation.uk.dashboard.DashboardImpl.goHome(DashboardImpl.java:91)
at com.gtech.automation.uk.dashboard.steps.footer.ConnectionInfoSteps.isConnectionClosed(ConnectionInfoSteps.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
at java.lang.reflect.Method.invoke(Method.java:620)
at cucumber.runtime.Utils$1.call(Utils.java:34)
at cucumber.runtime.Timeout.timeout(Timeout.java:13)
at cucumber.runtime.Utils.invoke(Utils.java:30)
at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:35)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:298)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:48)
at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:91)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
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 cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:93)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:37)
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 cucumber.api.junit.Cucumber.run(Cucumber.java:98)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

These are the configuration i have used

Selenium version :2.53.0 Firefox version 46

I have checked the port 7055 its not active netstat -ntlp | grep 7055

however Xvfb is running on the linux server netstat -ntlp | grep Xvfb tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 31384/Xvfb

I tried running the Xvfb server with port number its not working Xvfb :1 -screen 0 1024x768x16 -nolisten inet6 -port 7055 -from localhost.localdomain

Please help on this

Code

public static WebDriver getWebDriver(WebDriverImplementation implementation) {
    switch (implementation) {
        case FIREFOX:

            return new FirefoxDriver(getFirefoxCapabilities());
        case FIREBUG: {
            FirefoxProfile firefoxProfile = new FirefoxProfile();
            String seleniumPath = System.getProperty("selenuim.webdriver.path");
            try {
                firefoxProfile.addExtension(new File(seleniumPath + "/" + FIREBUG_FILENAME));
            }catch (NullPointerException e)
            {
                logger.log(Level.SEVERE, null, e);
            } catch(Exception e) {
               System.out.println("Unexcepted Exception");
                logger.log(Level.SEVERE, null, e);
            }
            firefoxProfile.setPreference("extensions.firebug.currentVersion", FIREBUG_VERSION);
            firefoxProfile.setPreference(seleniumPath, seleniumPath);

            DesiredCapabilities capabilities = getFirefoxCapabilities();
            capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);

            return new FirefoxDriver(capabilities);
        }
        case SHARED_FIREFOX:
            return new SharedFireFoxDriver();
        case MARIONETTE:
            return new MarionetteDriver(getFirefoxCapabilities());
        case INTERNET_EXPLORER:
            return new InternetExplorerDriver();
        default:
            String message = "Unable to find a web driver implemention for : " + implementation.name();
            logger.log(Level.SEVERE, message);
            throw new UnsupportedOperationException(message);
    }
}

0 Answers0