【问题标题】:Issue running firefox with xvfb-run (Selenium WebDriver)使用 xvfb-run (Selenium WebDriver) 运行 firefox 问题
【发布时间】:2013-05-01 12:18:17
【问题描述】:

我有一个 java 应用程序,它使用 Selenium Webdriver 登录到一个站点,检查特定文本并在找到它们时给我发电子邮件。我有一个每天早上运行 jar 文件并每天晚上停止它的 cron 作业。

它使用firefox但无头运行,这是命令

xvfb-run --auto-servernum --server-num=0 nohup /usr/bin/java -jar A.jar

当它试图打开 Firefox 时,会抛出以下内容:

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
 *** Item Installed via directory addition to Install Location: app-global Item ID: {972ce4c6-7e08-4474-a285-3208198ce6fd}, attempting to register...
 *** Item Installed/Upgraded at Install Location: app-global Item ID: {972ce4c6-7e08-4474-a285-3208198ce6fd}, attempting to register...
 *** Blocklist::_loadBlocklist: no XML File found
*** ... success, item is compatible
*** Item Installed via directory addition to Install Location: app-profile Item ID: fxdriver@googlecode.com, attempting to register...
*** Item Installed/Upgraded at Install Location: app-profile Item ID: fxdriver@googlecode.com, attempting to register...
*** ... success, item is compatible at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:106)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:190)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:179)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)
    at auth.Authenticator.<init>(Authenticator.java:27)
    at reader.ReaderThread.run(ReaderThread.java:70)

奇怪的是,当我使用 x2go 并登录到 debian 机器时,程序运行正常。我可以看到 Firefox 正在打开、登录并按照应有的方式进行所有操作。

我在 Firefox 14 中使用 2.31 版本,正如我所说,当我生成桌面会话并登录到该框时,它可以正常工作。

知道为什么它不起作用吗?我想我现在可以更新到 2.32 了,但我认为这不是问题,因为它在某些情况下可以正常工作,而在其他情况下则不行。

P.S 如果我让它在我的 Windows eclipse 实例中运行,它没有任何问题。

提前感谢您的帮助

【问题讨论】:

  • 它实际上是在 2.32 上运行的。

标签: java selenium-webdriver xvfb


【解决方案1】:

您是否传递了 DISPLAY 参数?我发现 Firefox 没有它会犹豫(在无头运行时)

Xvfb :0 -ac -screen 0 1024x768x24 &

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-28
    • 2013-06-07
    相关资源
    最近更新 更多