远程WebDriver UnreachableBrowserException:无法启动新的会话 [英] Remote WebDriver UnreachableBrowserException: Could not start a new session
问题描述
我在所有浏览器中都遇到了这个例外.例如,我在chrome上创建一个远程Webdriver,如下所示:
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);
我得到了UnreachableBrowserException,如下所示:
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.
但是我在http://myIP:4444/grid/console
处检查了我的硒集线器,一切都很好,该节点是stil注册的.然后,我在http://myIP:5555/wd/hub/static/resource/hub.html
上检查我的节点,仍然可以单击创建会话"为所有浏览器创建一个会话.
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.
我今天才遇到这个异常,它在几天前仍然有效.我正在使用Selenium 3.11.0,IntelliJ 2017.3,所有驱动程序和浏览器都是最新版本.
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.
我在这里用Google搜索,但是当我的网格仍在运行时,找不到解决方案.任何帮助,不胜感激.
I googled here, but I can't find a solution for this while my gird is still running. Any help much appreciated.
推荐答案
错误说明了一切:
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
调用 RemoteWebDriver 时 Selenium 的当前实现支持ChromeOptions
,您可以使用以下代码块:
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);
更新
根据您的评论更新 seleniumhq文档上的文档更新.以下是 Selenium发行说明的相关字节:
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`.
这篇关于远程WebDriver UnreachableBrowserException:无法启动新的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!