我有运行测试的盒子。詹金斯似乎会进入并执行正在运行的特定作业中描述的命令。
在这里,我正在尝试运行我的 Selenium Webdriver 测试,但它告诉我在启动 firefox 时出错。最终的想法是完全在这个盒子上运行 webtests,并截取一些错误截图。
我正在使用 selenium-java-2.25.jar、firefox 10、linux 操作系统。
有趣的是,我可以手动 ssh 进入盒子,暂时从盒子上的另一个用户那里复制魔法 cookie(以获得 X 隧道),执行export DISPLAY=mydisplay:1.0
,然后使用 ant 启动我的 selenium 测试。这将带来 Firefox 和测试就好了。
这里有各种线程似乎有完全相同的问题,我想我已经尝试了其中的大部分。这是我所做的:
重新启动盒子,使用 VNC 重新登录。
在运行 selenium 测试之前在 Jenkins 中放置一个 bash 脚本来运行。bash 脚本基本上只是做一个
export DISPLAY=mydisplay:1.0
. 它也执行xclock
. 这很有效,因为我可以看到 xclock 显示在 VNC 中。iptables 已关闭
firefox 正确位于 /usr/bin/firefox
sshd_config 显示 X11Forwarding 为真。
据说降级 Firefox 对某些人有帮助,但我不希望这样做。Webdriver 无论如何都应该支持 FF 10。
但是,以上都不能解决问题。
本地主机上的端口 7055 似乎不存在:
netstat -an | grep 7055
- 没有打印
这就是我的 /etc/hosts 所说的:
1 127.0.0.1 localhost.localdomain localhost
2 ::1 localhost6.localdomain6 localhost6
也许它与 localhost:7055 不存在有关?我不确定从这里去哪里。仍然,为什么错误输出说它display: :0.0
在我指定时正在寻找mydisplay:1.0
?
最后我收到的错误输出:
[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)