テストを実行するボックスがあります。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で再度ログインします。 
- 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)