Selenium挂起实例化FirefoxDriver

我尝试开始使用selenium(今天下载了当前版本)并复制了他们打开浏览器并执行谷歌搜索的示例。

但是,该程序永远挂在第一行WebDriver driver = new FirefoxDriver();

我安装了Firefox 13。

线程转储:
线程[主要]
   Thread.sleep(long)行:不可用[native method] [local variables unavailable]
   FirefoxBinary.sleep(长)行:218
   FirefoxBinary.clean(FirefoxProfile,File)行:234
   NewProfileExtensionConnection.start()行:76
   FirefoxDriver.startClient()行:200
   FirefoxDriver(RemoteWebDriver)。(CommandExecutor,Capabilities)行:94
   FirefoxDriver。(FirefoxBinary,FirefoxProfile)行:147
   FirefoxDriver。()行:85
   Test.main(String [])行:24

这些情况通常是因为Firefox和Selenium在兼容性方面有点“不同步”。

您应该尝试两件事:将Selenium更新为最新版本和/或降级Firefox。 密切关注Selenium发行说明

在Selenium 2.23中添加了Firefox 13支持。 请参阅http://code.google.com/p/selenium/source/browse/trunk/java/CHANGELOG

通常新浏览器很热 – 我在其他地方寻找问题。 Webdriver或selenium服务器。 http://d.pr/i/Q5Dt

我一直在使用Firefox 18,但我刚刚自动更新到19,这似乎打破了webdriver。 Mozilla与之前版本的链接并不突出:

https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/18.0b7/mac/en-US/

尝试在没有显示设置的无头CentOS服务器上实例化webdriver时看到此行为。

根据https://serverfault.com/questions/363827/how-can-i-run-firefox-on-centos-with-no-display – 您可以使用Xvfb ,它可以为您提供不需要的X服务器连接到物理显示器