selenium exceptionin java(org.openqa.selenium.remote.UnreachableBrowserException)

时间:2014-03-15 15:14:40

标签: java selenium selenium-webdriver

我知道有多少线程在运行,但没有一个解决这个问题。我正在尝试使用selenum获取aspx页面。但是它会在这行代码WebDriver driver = new ChromeDriver();中抛出UnreachableBrowserException。 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。

1 个答案:

答案 0 :(得分:4)

我已下载chromedriver而不是将路径设置为chrome.exe我将路径设置为chromedriver.exe并且它有效。 C:\ Program Files(x86)\ chromedriver \ chromedriver.exe