4
我試圖在Mac OS X 10.6.3上使用WebDriver爲Web應用程序運行無頭測試。我的計劃是用Xvfb運行firefox-x11,但WebDriver無法啓動firefox-x11。我的代碼是:在Mac上使用firefox-x11的WebDriver
System.setProperty("webdriver.firefox.bin",
"/opt/local/bin/firefox-x11-devel-standalone");
WebDriver browser = new FirefoxDriver();
try {
browser.get("http://google.com");
} finally {
browser.close();
}
但這種失敗:
org.openqa.selenium.WebDriverException: Unable to start firefox cleanly.
Exit value: 1
Ran from: [/opt/local/bin/firefox-x11-devel-standalone, --verbose, -silent]
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.6.3', java.version: '1.6.0_17'
Driver info: driver.version: firefox
at org.openqa.selenium.firefox.FirefoxBinary.copeWithTheStrangenessOfTheMac(FirefoxBinary.java:200)
at org.openqa.selenium.firefox.FirefoxBinary.startProfile(FirefoxBinary.java:83)
at org.openqa.selenium.firefox.FirefoxBinary.clean(FirefoxBinary.java:264)
at org.openqa.selenium.firefox.FirefoxLauncher.startProfile(FirefoxLauncher.java:66)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.<init>(NewProfileExtensionConnection.java:45)
at org.openqa.selenium.firefox.internal.ExtensionConnectionFactory.connectTo(ExtensionConnectionFactory.java:44)
當我手動啓動/opt/local/bin/firefox-x11-devel-standalone
從終端,它似乎很好地工作,儘管顯示出一些harmless errors。所以,我試圖修補org.openqa.selenium.firefox.FirefoxBinary.copeWithTheStrangenessOfTheMac(ProcessBuilder)
方法忽略錯誤和1.現在它進一步進行出口值,但失敗:
Caused by: org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/opt/local/bin/firefox-x11-devel-standalone) on port 7055; process output follows:
Xlib: extension "RANDR" missing on display "/tmp/launch-tElCRZ/org.x:0".
Dynamic session lookup supported but failed: launchd did not provide a socket path, verify that org.freedesktop.dbus-session.plist is loaded!
(firefox-bin:88837): Gtk-CRITICAL **: gtk_widget_has_screen: assertion `GTK_IS_WIDGET (widget)' failed
ˇXlib: extension "RANDR" missing on display "/tmp/launch-tElCRZ/org.x:0".
Dynamic session lookup supported but failed: launchd did not provide a socket path, verify that org.freedesktop.dbus-session.plist is loaded!
(firefox-bin:88877): Gtk-CRITICAL **: gtk_widget_has_screen: assertion `GTK_IS_WIDGET (widget)' failed
ˇ
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.6.3', java.version: '1.6.0_17'
Driver info: driver.version: firefox
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.connectToBrowser(NewProfileExtensionConnection.java:60)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.<init>(NewProfileExtensionConnection.java:49)
at org.openqa.selenium.firefox.internal.ExtensionConnectionFactory.connectTo(ExtensionConnectionFactory.java:44)
... 4 more
Caused by: org.openqa.selenium.firefox.NotConnectedException: Failed to start up socket within 45000
at org.openqa.selenium.firefox.internal.AbstractExtensionConnection.connectToBrowser(AbstractExtensionConnection.java:143)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.connectToBrowser(NewProfileExtensionConnection.java:58)
... 6 more
有沒有人有來的webdriver與Firefox-X11的工作? This post似乎表明,一個人已經得到它的工作,但它不包含太多的細節。
我無法從WebDriver啓動firefox-x11。我的嘗試是首先使用X11運行,然後轉到Xvfb。什麼是設置'$ DISPLAY'的正確方法? – 2010-05-17 15:27:50
如果要這樣做,請將$ DISPLAY設置爲未啓動生成的內容(即:0.0)。自動X11服務器啓動不適合無頭進程。 – 2010-05-17 17:14:27