Reputation:
I am using Selenium to test my website, it opens up a URL using Firefox, logins and does some stuff on the page and then logs out and shuts firefox. That all works great on Windows 7. The code starts with:
WebDriver driver = new FirefoxDriver();
driver.get(URL);
Now I deployed my jar in linux box that runs Debian lenny which has iceweasel on it. A cron job starts the program which throws the following error when trying to open firefox:
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: :0 Error: cannot open display: :0
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:106) at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:110) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:190) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:183) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:179) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:92) at auth.Authenticator.authenticate(Authenticator.java:15) at reader.ReaderThread.run(ReaderThread.java:67) org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: Error: cannot open display: :0 Error: cannot open display: :0
Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: os.name: 'Linux', os.arch: 'i386', os.version: '2.6.26-2-686', java.version: '1.6.0_26' Driver info: driver.version: FirefoxDriver at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118) at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:110) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:190) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:183) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:179) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:92) at auth.Authenticator.authenticate(Authenticator.java:15) at reader.ReaderThread.run(ReaderThread.java:67)
I have Xvfb running ok in the box and I have set variable DISPLAY to 0. I have searched around and none of the solutions (like setting the env variable) worked.
Isnt XVfb supposed to work as a non-graphical environment that the browser will launch into and do the necessary actions? What's stopping it from starting up?
I am using the latest Selenium version 2.31 and Firefox 3.0.6 Iceweasel.
Edit: Updated to Firefox 14 and still see the same issue. I even raised the timeout limit to 60 seconds.
driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
SOLVED: By running it with the xvfb wrapper, xvfb-run like this:
export DISPLAY=:0.0
xvfb-run --auto-servernum --server-num=0 nohup java - jar X.jar
Upvotes: 6
Views: 15509
Reputation: 21480
This issue get resolved after upgraded to the latest Selenium jar.
Upvotes: -2
Reputation: 375
I have seen the similar issue and this is coming only for firefox, for other browser everything was working fine, I tried on Chrome. Here is the solution for this 1. Check the version of FF, if it is latest, then go for a lesser version of FF. It is recommended for more stability. 2. And you should always try to take latest selenium binary from selenium website. For more details try this solution: http://khyatisehgal.wordpress.com/2014/09/09/at-org-openqa-selenium-firefox-internal-newprofileextensionconnection-startnewprofileextensionconnection-java106/
Upvotes: 0
Reputation:
Solved by doing this:
export DISPLAY=:0.0 xvfb-run --auto-servernum --server-num=0 nohup java - jar X.jar
Upvotes: 4
Reputation: 183
Either try to update your webdriver or downgrade your firefox. this issue is related that selenium server cannot connect to your firefox.
Upvotes: -1