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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22425565/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 15:39:22  来源:igfitidea点击:

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

javaseleniumselenium-webdriver

提问by Shawn

I know there are number of threads running but none of them has a solution of this problem. I am trying to get a aspx page using selenum. But it throws UnreachableBrowserException at this line of code WebDriver driver = new ChromeDriver();. An instance of chrome is opening but then later on after few seconds it throws the exception I have mentioned above.

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

Here is my sample code.

这是我的示例代码。

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();

Following is the stacktrace.

以下是堆栈跟踪。

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

I have red number of articles but couldnot find any solution. My chrome version is 33.0.1750.154 m.

我有红色文章,但找不到任何解决方案。我的 chrome 版本是 33.0.1750.154 m。

采纳答案by Shawn

I have downloaded chromedriverand instead of setting path to chrome.exeI set the path to chromedriver.exeand it worked. C:\Program Files(x86)\chromedriver\chromedriver.exe

我已经下载chromedriver并没有设置路径,chrome.exe而是设置了路径chromedriver.exe并且它起作用了。 C:\Program Files(x86)\chromedriver\chromedriver.exe