本文介绍了Selenium Webdriver - Debian Lenny上的FirefoxDriver问题(错误无显示)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Selenium来测试我的网站,它使用Firefox打开一个URL,登录并在页面上做一些事情,然后注销并关闭firefox。这一切在Windows 7上运行良好。代码以:

I am using Selenium to test my website, it opens up a URL using Firefox, logins and does some stuff on the page and then logs out and shuts firefox. That all works great on Windows 7. The code starts with:

WebDriver driver = new FirefoxDriver();
driver.get(URL);

现在我在运行Debian lenny的linux框中部署了我的jar,它上面有iceweasel。一个cron作业启动该程序,在尝试打开firefox时抛出以下错误:

Now I deployed my jar in linux box that runs Debian lenny which has iceweasel on it. A cron job starts the program which throws the following error when trying to open firefox:

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。(RemoteWebDriver.java:110)
at
org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:190)
at
org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:183)
at
org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:179)
at
org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:92)
at auth.Authenticator.authenticate(Authenticator.java:15)at
reader.ReaderThread.run(ReaderThread .java:67)
org.openqa.selenium.WebDriverException:无法连接到二进制
FirefoxBinary(/ usr / bin / fir) efox)在7055端口;进程输出如下:
错误:无法打开显示:: 0错误:无法打开显示:: 0

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.(RemoteWebDriver.java:110) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:190) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:183) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:179) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:92) at auth.Authenticator.authenticate(Authenticator.java:15) at reader.ReaderThread.run(ReaderThread.java:67) org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: Error: cannot open display: :0 Error: cannot open display: :0

构建信息:版本:'未知',修订版: '未知',时间:'未知'
系统信息:os.name:'Linux',os.arch:'i386',os.version:
'2.6.26-2-686', java.version:'1.6.0_26'驱动程序信息:driver.version:
FirefoxDriver at
org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
at
org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244)
at
org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:110)
at
org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:190)
at
org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:183 )
at
org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:179)
at
org.openqa.selenium.firefox.FirefoxD河流。(FirefoxDriver.java:92)
at auth.Authenticator.authenticate(Authenticator.java:15)at
reader.ReaderThread.run(ReaderThread.java:67)

Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: os.name: 'Linux', os.arch: 'i386', os.version: '2.6.26-2-686', java.version: '1.6.0_26' Driver info: driver.version: FirefoxDriver at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118) at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:110) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:190) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:183) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:179) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:92) at auth.Authenticator.authenticate(Authenticator.java:15) at reader.ReaderThread.run(ReaderThread.java:67)

我已经在框中运行了Xvfb,并且我已将变量DISPLAY设置为0.我已经搜索过并且没有任何解决方案(如设置env变量)工作。

I have Xvfb running ok in the box and I have set variable DISPLAY to 0. I have searched around and none of the solutions (like setting the env variable) worked.

Isnt XVfb应该作为浏览器启动的非图形环境工作并执行必要的操作吗?什么阻止它启动?

Isnt XVfb supposed to work as a non-graphical environment that the browser will launch into and do the necessary actions? What's stopping it from starting up?

我使用的是最新的Selenium版本2.31和Firefox 3.0.6 Iceweasel。

I am using the latest Selenium version 2.31 and Firefox 3.0.6 Iceweasel.

编辑已更新至Firefox 14,但仍然看到同样的问题。我甚至将超时限制提高到60秒。

Updated to Firefox 14 and still see the same issue. I even raised the timeout limit to 60 seconds.

driver.manage()。timeouts()。pageLoadTimeout(60,TimeUnit.SECONDS);

driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);

已解决:通过使用xvfb包装器运行它,xvfb-run如下:

SOLVED: By running it with the xvfb wrapper, xvfb-run like this:

export DISPLAY=:0.0
xvfb-run --auto-servernum --server-num=0 nohup java - jar X.jar


推荐答案

解决这个问题:

export DISPLAY=:0.0 xvfb-run --auto-servernum --server-num=0 nohup java - jar X.jar

这篇关于Selenium Webdriver - Debian Lenny上的FirefoxDriver问题(错误无显示)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 19:38