2013-05-01 138 views
5

我有一个使用Selenium Webdriver登录到网站的Java应用程序,检查特定文本并发送给我,如果它发现它们。我有一个cron作业,每天早上运行jar文件并每天晚上停止它。使用xvfb-run(Selenium WebDriver)运行firefox问题

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

xvfb的运行--auto-SERVERNUM --server-NUM = 0的nohup的/ usr /斌/ Java的罐子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: [email protected], attempting to register... 
*** Item Installed/Upgraded at Install Location: app-profile Item ID: [email protected], 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实例中运行,它没有任何问题。

在此先感谢您的帮助

+1

它实际上运行在2.32上。 – blondeamon 2013-05-01 20:44:21

回答

0

您是否传递DISPLAY参数?我发现Firefox会在没有它的情况下运行(当运行无头时)

Xvfb :0 -ac -screen 0 1024x768x24 & 
+0

同意@Emanuele Ciurleo – Abhinav 2016-02-09 13:23:28

相关问题