当前位置: 首页 > 知识库问答 >
问题:

远程WebDriver UnreachableBrowserException:无法启动新会话

谷梁宏恺
2023-03-14

我在所有浏览器中都遇到了这个例外。例如,我在chrome上创建了一个远程webdriver,如下所示:

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如下:

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,一切正常,节点仍然注册。然后在<代码>http://myIP:5555/wd/hub/static/resource/hub.html,我仍然可以单击“创建会话”为所有浏览器创建会话。

我今天刚刚得到这个例外,几天前它仍然有效。我使用的是Selenium 3.11.0、IntelliJ 2017.3,所有驱动程序和浏览器都是最新版本。

我在这里搜索了一下,但在我的网格仍在运行时,我找不到解决方案。非常感谢您的帮助。

共有1个答案

曹子平
2023-03-14

错误说明了一切:

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

当前的Selenium实现在调用RemoteWebDriver时支持ChromeOptions,您可以使用以下代码块:

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

根据您的评论更新,seleniumhq-留档尚未更新。以下是Selenium发行说明中的相关字节:

>

  • Selenium v3.5.0:

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

    硒v3.6.0:

    * All `*Option` classes now extend `MutableCapbilities`
      `new RemoteWebDriver(new ChromeOptions());`
    

    硒v3.7.0:

    * Migrated from using `DesiredCapabilities` to either
      `MutableCapabilities` or (preferably) `ImmutableCapabilities`.
    

  •  类似资料:
    • 我正试图使用Appium从mac上的Android应用程序启动我的应用程序。应用程序 或使用我的代码,但我得到一个错误 无法启动新会话。 确保Appium服务器运行的应用程序是通过使用Appium中的“App Path”参数打开的。应用程序(以及适用于Android的软件包和 活动)或通过连接selenium客户端,并 在所需的功能对象中提供此功能。" 下面是我的Appium日志,我在这里做错了什

    • 这是我的密码。我是Appium的初学者,我正在使用Java版本13和最新版本的Eclipse和Appium,我已经尝试了所有方法,但每次都会遇到以下异常: 失败:运行组织。openqa。硒。SessionNotCreatedException:无法创建新的远程会话。有关详细信息,请查看服务器日志。原始错误:处理命令时发生未知的服务器端错误。原始错误:无法初始化检测过程。确保被测应用程序未崩溃,并调

    • 我正试图使用Selenium Grid启动一款新的Chrome浏览器,但最终出现以下错误 无法创建新的远程会话。所需功能=能力[{浏览器名称=chrome,版本=55.0.2,平台=WINDOWS}],所需功能=能力[{}]构建信息:版本:“3.0.1”,修订版本:“1969d75”,时间:“2016-10-18 09:49:13 -0700”系统信息:主机:“PL9710388”,ip:“10.

    • 当我尝试运行测试时,我得到这个错误。 sessionNotCreatedException:无法创建新的远程会话。所需功能=功能[{PlatformName=Android,DeviceName=F4AZFG07P508}],所需功能=功能[{}]生成信息:版本:“3.3.1”,修订版:“5234B325D5”,时间:“2017-03-10 09:10:29+0000”系统信息:主机:“MacBo

    • null 我的脚本中使用的代码: 详细的堆栈跟踪: an 19,2017 6:07:36 PM org.openqa.selenium.remote.ProtocolHandshake创建session信息:尝试双方言会话,假设Postel定律在远程端成立,Jan 19,2017 6:07:37 PM org.openqa.selenium.remote.ProtocolHandshake创建se

    • 我正在尝试使用selenium java代码打开firefox浏览器。 Selenium服务器已启动并正在运行。我尝试使用命令提示符更改selenium服务器端口,并在代码中设置端口,但两者都不起作用。 在错误消息“连接到localhost:6544”中,它每次都试图连接到不同的localhost。有人能看出问题出在哪里吗? 我使用的版本有: firefox 48.0 另外,我的geckodriv