Remote 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
检查了我的 selenium hub,一切都很好,节点仍然注册.然后我在 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.
我在这里用谷歌搜索过,但是当我的网格仍在运行时,我找不到解决方案.非常感谢任何帮助.
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()`
Selenium 在调用 RemoteWebDriver 时的当前实现支持 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-documentation 上的文档更新.以下是 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`.
这篇关于Remote WebDriver UnreachableBrowserException:无法启动新会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!