一尘不染

Java中的selenium异常(org.openqa.selenium.remote.UnreachableBrowserException)

selenium

我知道正在运行的线程数量很多,但是没有一个可以解决此问题。我正在尝试使用selenum获取aspx页面。但是它在这行代码中抛出UnreachableBrowserException
WebDriver driver = new ChromeDriver();。chrome实例正在打开,但随后几秒钟后,它抛出了我上面提到的异常。

这是我的示例代码。

System.setProperty("webdriver.chrome.driver", 
           "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");

        WebDriver driver = new ChromeDriver();
        driver.get("http://some aspx page with form");
            System.out.println("!!!!! Got the page !!!!!");
            driver.close();
            driver.quit();

以下是堆栈跟踪。

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.40.0', revision: 'fbe29a9', time: '2014-02-19 20:54:28'
System info: host: 'E7D4C9EFE70614', ip: '192.168.1.12', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_45'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:567)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218)
    at org.openqa.selenium.chrome.ChromeDriver.startSession(ChromeDriver.java:181)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:113)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:117)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:160)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:149)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:106)
    at HtmlParser.main(HtmlParser.java:31)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.40.0', revision: 'fbe29a9', time: '2014-02-19 20:54:28'
System info: host: 'E7D4C9EFE70614', ip: '192.168.1.12', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_45'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:546)
    ... 8 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:12233/status] to be available after 20008 ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
    ... 10 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)
    ... 11 more
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.FutureTask.get(Unknown Source)
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
    ... 12 more

我的文章数量很多,但找不到任何解决方案。我的Chrome版本是33.0.1750.154 m。


阅读 814

收藏
2020-06-26

共1个答案

一尘不染

我已经下载了chromedriver,而不是设置路径,而是将路径chrome.exe设置为chromedriver.exe工作了。 C:\
Program Files(x86)\ chromedriver \ chromedriver.exe

2020-06-26