I have box where I run tests. It seems like Jenkins would ssh in and execute commands described in the specific job that's running.
Here I am trying to run my Selenium Webdriver tests, but it tells me that I have errors in launching firefox. The end idea is to run the webtests on this box entirely, and also take some screenshots of errors.
I am using selenium-java-2.25.jar, firefox 10, linux OS.
The funny thing is that I can ssh in manually into the box, temporarily copy the magic cookie from another user on the box (to get an X tunnel), do an export DISPLAY=mydisplay:1.0
, then launch my selenium tests using ant. And this will bring up firefox and the tests just fine.
There are various threads here that seem to have the exact same problem, and I think I've tried most of them. Here is what I've done:
Reboot the box, log back in with VNC.
Placed a bash script in Jenkins to run before running selenium tests. The bash script basically just does an export DISPLAY=mydisplay:1.0
. It also executes xclock
. This works as I can see xclock being displayed in the VNC.
iptables have been turned off
firefox is correctly located in /usr/bin/firefox
sshd_config shows having X11Forwarding as true.
Supposedly downgrading firefox helped some people, but I do not wish to do this. Webdriver should support FF 10 anyway.
However, none of the above solves the problem.
It doesn't seem like port 7055 on localhost even exists:
netstat -an | grep 7055
- Nothing prints
This is what my /etc/hosts says:
1 127.0.0.1 localhost.localdomain localhost
2 ::1 localhost6.localdomain6 localhost6
Perhaps it has something to do with localhost:7055 not existing? I am unsure where to go from here. still, why does the error output say it's looking for display: :0.0
when I've specified mydisplay:1.0
?
And finally the error output I receive:
[testng] org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
[testng] Xlib: connection to ":0.0" refused by server
[testng] Xlib: No protocol specified
[testng]
[testng] Error: cannot open display: :0.0
[testng] Xlib: connection to ":0.0" refused by server
[testng] Xlib: No protocol specified
[testng]
[testng] Xlib: connection to ":0.0" refused by server
[testng] Xlib: No protocol specified
[testng]
[testng] Xlib: connection to ":0.0" refused by server
[testng] Xlib: No protocol specified
[testng]
[testng] Error: cannot open display: :0.0
[testng]
[testng] at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:109)
[testng] at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:245)
[testng] at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:109)
[testng] at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:185)
[testng] at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:178)
[testng] at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:174)
[testng] at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)
[testng] at com.test.webtest.browser.BrowserFactory.createBrowser(BrowserFactory.java:24)
[testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[testng] at java.lang.reflect.Method.invoke(Method.java:601)
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…