Remote WebDriver UnreachableBrowserException: Could not start a new session

删除回忆录丶 提交于 2019-11-30 09:50:14

问题


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.


回答1:


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`.
    


来源:https://stackoverflow.com/questions/49492697/remote-webdriver-unreachablebrowserexception-could-not-start-a-new-session

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!