UnreachableBrowserException trying to launch in Se

2019-02-19 19:44发布

I have a set of automations that work fantastically in Firefox and Chrome, and I'd like to launch an instance of IEDriver as well.

I've set up IEDriver as per Selenium's Google Code wiki, with the correct path (if I change the path I get a different exception, so it's definitely correct). But for some reason it still can't launch, and just times out.

The code to launch it (the last line throws the exception):

        File ieDriver = new File("C:/Users/whatever/path/IEDriverServer.exe");
        System.setProperty("webdriver.ie.driver", ieDriver.getAbsolutePath());
        WebDriver ie = new InternetExplorerDriver();

And the exception is:

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.33.0', revision: '4ecaf82108b2a6cc6f006aae81961236eba93358', time: '2013-05-22 12:00:17'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_21'
Driver info: driver.version: InternetExplorerDriver
    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.startSession(RemoteWebDriver.java:201)
    at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:184)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:174)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:143)
    at uk.co.know.kiteTest.WebDriverManager.<init>(WebDriverManager.java:52)
    at uk.co.know.kiteTest.RunAutomations.main(RunAutomations.java:13)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.33.0', revision: '4ecaf82108b2a6cc6f006aae81961236eba93358', time: '2013-05-22 12:00:17'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_21'
Driver info: driver.version: InternetExplorerDriver
    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:527)
    ... 7 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:38622/status] to be available after 20014 ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
    ... 9 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)
    ... 10 more

7条回答
forever°为你锁心
2楼-- · 2019-02-19 19:54

Selenium WebDriver with Chrome, issue:

(org.openqa.selenium.remote.UnreachableBrowserException) solution
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.35.0', revision: '8df0c6b', time: '2013-08-12 15:43:19'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_40'
Driver info: driver.version: ChromeDriver

If you are getting above problem, go to the chromedriver.exe location and try to execute the exe. If you are able to execute the exe then below code will work. Otherwise it will be a permission issue to the chromedriver folder. Change the folder location or provide the permission to the folder and double click on chromedriver.exe.

Solution:

  System.setProperty("webdriver.chrome.driver", "C:/Driver/chromedriver.exe");
  System.out.println(System.getProperty("webdriver.chrome.driver"));

  WebDriver driver3 = new ChromeDriver();
查看更多
劫难
3楼-- · 2019-02-19 19:54

I had the same issue. This fixed it for me:

DesiredCapabilities capabilitiesIE = DesiredCapabilities.internetExplorer();
capabilitiesIE.setCapability(
    InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver = new InternetExplorerDriver(capabilitiesIE);
查看更多
4楼-- · 2019-02-19 20:00

I was hitting this same error and then found this question. In my case, it turned out that I had the 64 bit version of the IEDriver.exe on my system, but I was on a 32 bit windows platform. So this error was indicating that the OS failed to execute the driver program. I tried to run the driver directly in a command prompt to see that infact the 32 bit OS was not recognizing the 64 bit driver exe as an executable program.

Getting the correct 32 bit IEDriver.exe solved my problem.

查看更多
Explosion°爆炸
5楼-- · 2019-02-19 20:09

Go to hosts (C:\Windows\system32\drivers\etc) and make sure that you have this line correctly: 127.0.0.1 localhost

查看更多
Fickle 薄情
6楼-- · 2019-02-19 20:11

Faced similar exception while trying to execute Selenium script over BrowserStack for mobile devices. And often found this exception being thrown. Eventually realized being virtual machines involved, emulators were taking time to boot up and thus causing UnreachableBrowserException.

Wrote below code to handle this, by setting Number of times to retry(RetryCount) and made multiple attempts(retryAttempt) to check Remote WebDriver's availability.

while(retryAttempt<=retryCount){
            try{

                WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
                return driver;
            }
            catch(UnreachableBrowserException e){
                Thread.sleep(10000);
                if(retryAttempt>retryCount){
                    logger.error("Remote Web Driver cannot be reached at this moment");
                }
            }
        }
查看更多
贪生不怕死
7楼-- · 2019-02-19 20:16

It seems to me you use improper driver initilization. Try piece of code from my project:

File file = new File("C:/Selenium/iexploredriver.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driver = new InternetExplorerDriver();
查看更多
登录 后发表回答