テストを実行するボックスがあります。Jenkins は、実行中の特定のジョブに記述されているコマンドを ssh して実行するようです。
ここで Selenium Webdriver テストを実行しようとしていますが、Firefox の起動中にエラーが発生したと表示されます。最終的なアイデアは、このボックス全体で Web テストを実行し、エラーのスクリーンショットをいくつか撮ることです。
私はselenium-java-2.25.jar、firefox 10、linux OSを使用しています。
おもしろいことに、ボックスに手動で SSH 接続し、ボックス上の別のユーザーからマジック クッキーを一時的にコピーして (X トンネルを取得するため)、 を実行してexport DISPLAY=mydisplay:1.0
から、ant を使用してセレン テストを起動できます。そして、これによりFirefoxが起動し、テストは問題なく実行されます。
ここにはまったく同じ問題があると思われるさまざまなスレッドがあり、それらのほとんどを試したと思います。これが私がやったことです:
ボックスを再起動し、VNC で再度ログインします。
Selenium テストを実行する前に実行する Jenkins に bash スクリプトを配置しました。基本的に、bash スクリプトは単に
export DISPLAY=mydisplay:1.0
. も実行しxclock
ます。これは、VNC に xclock が表示されているのを確認できるので機能します。iptables がオフになっている
firefox は /usr/bin/firefox に正しく配置されています
sshd_config は、X11Forwarding が true であることを示しています。
Firefox のダウングレードが役に立った人もいると思いますが、私はそうしたくありません。いずれにせよ、Webdriver は FF 10 をサポートする必要があります。
ただし、上記のいずれも問題を解決しません。
localhost のポート 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)