Remote WebDriver UnreachableBrowserException: Could not start a new session
Asked Answered
M

1

3

I got this exception for all browsers. For example, I create a remote webdriver on chrome like this:

caps = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
caps.setCapability(ChromeOptions.CAPABILITY, options);
webDriver = new RemoteWebDriver(new URL("http://myIP:5555/wd/hub"), caps);

And I got UnreachableBrowserException as follow:

org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`

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.

But I check my selenium hub at http://myIP:4444/grid/console, everything is fine, the node is stil registered. I then check my node at http://myIP:5555/wd/hub/static/resource/hub.html, I still can click "Create Session" to create a session for all browsers.

I just got this exception today, it still worked few days ago. I am using Selenium 3.11.0, IntelliJ 2017.3, all drivers and browsers are latest versions.

I googled here, but I can't find a solution for this while my gird is still running. Any help much appreciated.

Moffitt answered 26/3, 2018 at 13:30 Comment(0)
B
2

The error says it all :

INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`

The current implementation of Selenium while invoking RemoteWebDriver supports the ChromeOptions and you can use the following code block :

ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
webDriver = new RemoteWebDriver(new URL("http://myIP:5555/wd/hub"), options);

Update

As per your comment update the documentation at seleniumhq-documentation is yet to be updated. Here are the relevant bytes from the Selenium Release Notes :

  • Selenium v3.5.0 :

    * Start making *Option classes instances of Capabilities. This allows
      the user to do:
      `WebDriver driver = new RemoteWebDriver(new InternetExplorerOptions());`
    
  • Selenium v3.6.0 :

    * All `*Option` classes now extend `MutableCapbilities`
      `new RemoteWebDriver(new ChromeOptions());`
    
  • Selenium v3.7.0 :

    * Migrated from using `DesiredCapabilities` to either
      `MutableCapabilities` or (preferably) `ImmutableCapabilities`.
    
Bethel answered 26/3, 2018 at 14:24 Comment(5)
Thanks for your answer. Your code works. But I have some questions if you are so kind to answer them. 1) I just check Selenium Documentation here: seleniumhq.org/docs/04_webdriver_advanced.jsp, they still use DesiredCapabilities, which I followed and it worked for years, until today it doesn't work anymore. 2) As your suggestion, I changed it to ChromeOptions, it works actually, but I still get 'Using new ChromeOptions() is preferred to DesiredCapabilities.chrome().Moffitt
3) I also change to FirefoxOptions() and InternetExplorerOptions() for FF and IE, but it doesn't work like it does for Chrome. Could you please elaborate on this. Thanks so muchMoffitt
@Moffitt Check out my answer update and let me know if that answers your queries.Bethel
Thank you; it works with the new implementation. But I still still problem with FF. I will see into it.Moffitt
@Moffitt Feel free to raise a new question with your new requirement I will surely look into it.Bethel

© 2022 - 2024 — McMap. All rights reserved.