使用phantomjs,启动失败,出现org.openqa.selenium.net.UrlChecker$TimeoutException异常

发布于 2021-11-26 03:04:23 字数 4698 浏览 908 评论 2

主代码如下:

public static void main(String []args){
    	DesiredCapabilities caps = new DesiredCapabilities();
        caps.setJavascriptEnabled(true);       
        caps.setCapability("takesScreenshot", true); 
        caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,"/usr/local/bin/phantomjs");
        WebDriver driver = new PhantomJSDriver(caps);
        driver.get("http://www.google.com");
        WebElement element = driver.findElement(By.name("q"));
        String strToSearchFor = "Cheese!";
        element.sendKeys(strToSearchFor);
        element.submit();
        driver.quit();
	}


mac系统,依赖了以下jar包

<dependency>
	<groupId>org.seleniumhq.selenium</groupId>
	<artifactId>selenium-java</artifactId>
	<version>2.48.0</version>
</dependency>
<dependency>
       <groupId>com.github.detro.ghostdriver</groupId>
       <artifactId>phantomjsdriver</artifactId>
       <version>1.1.0</version>
</dependency>



程序启动报如下错误,真的是要崩溃了,试了很多办法都不行~求phantomjs大神帮帮忙好么

十一月 25, 2015 12:33:38 下午 org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
信息: executable: /usr/local/bin/phantomjs
十一月 25, 2015 12:33:38 下午 org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
信息: port: 3185
十一月 25, 2015 12:33:38 下午 org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
信息: arguments: [--webdriver=3185, --webdriver-logfile=/Users/xiaoshijie/Documents/workspace/BlogSpider/phantomjsdriver.log]
十一月 25, 2015 12:33:38 下午 org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
信息: environment: {}
env: node: No such file or directory
Exception in thread "main" 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.39.0', revision: '14fa800511cc5d66d426e08b0b2ab926c7ed7398', time: '2013-12-16 13:18:38'
System info: host: 'xiaoshijiedeMacintosh.local', ip: '192.168.1.54', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.1', java.version: '1.7.0_79'
Driver info: driver.version: PhantomJSDriver
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
	at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:110)
	at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
	at com.xiaoshijie.BlogSpider.util.PageUtil.main(PageUtil.java:57)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.39.0', revision: '14fa800511cc5d66d426e08b0b2ab926c7ed7398', time: '2013-12-16 13:18:38'
System info: host: 'xiaoshijiedeMacintosh.local', ip: '192.168.1.54', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.1', java.version: '1.7.0_79'
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:527)
	... 6 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:3185/status] to be available after 20002 ms
	at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
	at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
	... 8 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)
	... 9 more
Caused by: java.util.concurrent.TimeoutException
	at java.util.concurrent.FutureTask.get(FutureTask.java:201)
	at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
	... 10 more






如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

韬韬不绝 2021-11-30 08:59:05

不是的啊,我改成baidu,也不行的

岁吢 2021-11-30 01:57:18

你本地访问得了google么,确认不是因为被墙导致访问超时?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文