Selenium和PhantomJS - 等待驱动程序服务器启动超时

时间:2014-10-02 13:09:29

标签: java selenium phantomjs

我正在使用Selenium和GhostDriver以及PhantomJS从Java Webapp中截取网页页面。

我不知道为什么我会收到这个错误。我怀疑PhantomJSDriver正在使用服务器的公共IP,也许防火墙不满意......

该项目在我的本地计算机(OSX)上没有任何问题,但在服务器上没有任何问题(Debian 7)。

2014-10-02 12:29:49,089 [ajp-8009-3] ERROR HibernateFilter - exception caught in hibernate filter for request
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03 10:52:47'
System info: host: 'debian', ip: '8.8.8.8', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-028stab093.2', java.version: '1.6.0_
31'
Driver info: driver.version: PhantomJSDriver
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
        at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:110)
        at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
        at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:89)
        at ...
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03 10:52:47'
System info: host: 'debina', ip: '8.8.8.8', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-028stab093.2', java.version: '1.6.0_31'
Driver info: driver.version: PhantomJSDriver
        at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165)
        at org.openqa.selenium.phantomjs.PhantomJSCommandExecutor.execute(PhantomJSCommandExecutor.java:78)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:572)
        ... 36 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:14083/status] to be available after 20007 ms
        at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
        at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
        ... 38 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
        at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
        at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:79)
        ... 39 more
Caused by: java.util.concurrent.TimeoutException
        at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:258)
        at java.util.concurrent.FutureTask.get(FutureTask.java:119)
        at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
        ... 40 more

修改

我发现来自UnreachableBrowserException的主机和IP来自InetAddress.getLocalHost().getHostAddress()InetAddress.getLocalHost().getHostName()

超时实际上来自localhost地址Timed out waiting for [http://localhost:12518/status] to be available after 20010 ms

1 个答案:

答案 0 :(得分:0)

我遇到了类似的问题,但即使消息很接近,也与暂停无关。实际上,这是因为ghost驱动程序无法创建其日志文件。

检查您的日志中是否有此消息,如果是,请尝试更改权限以进行检查。