mac webdriver java_java – 在Mac上使用firefox-x11的WebDriver

我试图在Mac OS X 10.6.3上使用WebDriver对Web应用程序进行无头测试.我的计划是使用Xvfb运行firefox-x11,但WebDriver无法启动firefox-x11.我的代码是:

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.(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.(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似乎暗示一个人已经让它工作,但它没有包含太多细节.

最佳答案 看起来$DISPLAY设置不正确;它是由launchd而不是你配置Xvfb使用的显示器设置的.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值