【问题标题】:Unable to create new remote session with chromedriver无法使用 chromedriver 创建新的远程会话
【发布时间】:2016-11-08 08:44:36
【问题描述】:

我之前使用的是 selenium-server-standalone-2.53.1 和 chromedriver 2.22,我的验收运行良好。当我今天使用相同的版本运行它时,它开始失败并抛出 Unable to create a new remote session 错误。现在升级到 selenium-server-standalone-3.0.1 和 chromedriver-2.25 后,它抛出了几乎相同的错误。我不知道为什么会这样。我是 Selenium 的新手,非常感谢任何帮助。

升级后出错

Nov 08, 2016 4:27:54 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Nov 08, 2016 4:27:54 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Nov 08, 2016 4:27:54 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection

org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, version=, platform=ANY}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'xxx.yyy.com', ip: '172.19.10.212', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.8.0_60'
Driver info: driver.version: RemoteWebDriver

at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
at pet.furiend.website.selenium.test.acceptance.HomePageTest.setUp(HomePageTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

-----更新-----

对 webdriver url 进行更改后,它似乎开始了,但我现在又抛出一个错误。

java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map

at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:251)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:158)
at pet.furiend.website.selenium.test.acceptance.HomePageTest.setUp(HomePageTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

【问题讨论】:

  • 尝试更新您的 chrome 浏览器。
  • @lauda 我有最新的 chrome 浏览器、chromedriver 和 selenium 独立服务器

标签: selenium selenium-chromedriver


【解决方案1】:

如果您能让我们知道您的 Chrome 浏览器版本是什么,这将很有帮助,因为它会显着影响 ChromeDriver 的兼容性。例如,如果您不小心将 Chrome 浏览器更新到 54 版,那么您可能需要 ChromeDriver 2.25 才能使其正常工作。

只要您说它与您之前的设置一起工作; 我会把钱花在你真正的 Chrome 浏览器上(小心不要 chromeDriver)在你眼皮子底下更新;因此导致错误。整个组合:

  • Selenium 独立版

  • Chrome 驱动程序

  • Chrome 浏览器

在更改时确实很脆弱(出于这个原因,我个人强制我的浏览器不要自动更新)。如果您想强制 Chrome 浏览器 完全更新,只需转到 Chrome 路径并将 update 文件夹重命名为 update_old(标准 win 路径: C:\Program Files (x86)\Google\update)。这将禁止 Chrome 进行任何进一步的自动更新。

首先,如果我是你,我会尝试最新的 ChromeDriver v2.25 看看这是否能解决你的问题。你可以从这里下载latest ChromeDriver225

如果这不能解决您的问题,请尝试使用不同版本的 Chrome + ChromeDriver,直到您解决问题为止。 Selenium 不太容易更改,3.0.1 版应该可以与任何组合一起满足您的需求。在这里看看哪些版本的 ChromeDriver 与哪些版本的 Chrome 浏览器兼容。ChromeDriver Downloads/Compatibility

我可以确认最新的 Chrome 浏览器、ChromeDriver 和 Selenium 可以很好地协同工作。 所以在这里试试这个组合:

  • Chrome 浏览器 54.0.2840.87(撰写本文时的最新版本)
  • Chrome 驱动程序 2.25
  • 硒 3.0.1

祝你好运!

操作更新到最新版本的 ChromeDriver 后更新

正如我在下面的评论中提到的,我的选项可以 100% 与最新版本的 Chrome (54.0)、ChromeDriver (2.25) 和 Selenium (3.0.1) 一起使用。您可以先尝试评论您的所有功能并使用以下选项运行 chrome:

    System.setProperty("webdriver.chrome.driver", "C:\\projects\\test\\chromedriver.exe");
            ChromeOptions options = new ChromeOptions();  
            options.addArguments("test-type");
            options.addArguments("--disable-extensions");

所以你可以通过以下方式激活上述内容:

driver = new ChromeDriver(options);

现在关于功能,我认为您正在使用的版本没有获得或传达价值。如果您坚持使用它(我个人认为它毫无意义),您可以指定如下值,看看这是否适合您。

caps.setCapability("browser_version", "54.0.2840.87");

现在,你现在应该已经解决了,但如果真的出了问题,这实际上阻碍了你的工作,那么试试这个极其稳定的组合:

  • 铬 (48.0.2564.97) 来自 here
  • Chrome 驱动程序 (2.9) 来自 here
  • 硒 3.0.1

希望你这次能解决它,让我们知道你的进展如何!

【讨论】:

  • 谢谢@Xwris!我刚刚检查了我的 Chrome 浏览器版本,它是版本 54.0.2840.87(64 位)。我有你给出的确切组合,但它仍然给我在我的帖子中同样的错误。只是一个想法,我的 java 版本会是一个促成因素吗?
  • 您正在加载的功能中的某些内容似乎不正确(可能是缺少版本)?最好向我们发布您尝试使用 Chrome 加载的功能。同时,我将更新我的问题并发布我的选项,而不是 100% 有效的功能。或者,作为一个实验,您总是可以转移到另一个工作组合(以验证它是否可以实际工作),我也会在我的原始答案中发布。
【解决方案2】:

您似乎正在使用 OSX,您是否有可能使用终端应用程序启动测试?

我被这个错误困扰了一段时间,我通过取消选中高级终端应用程序设置中的“Set locale environment variables on startup”复选框设法解决了这个问题。 或者尝试使用此前缀启动您的测试:

LC_NUMERIC=”en_US.UTF-8″ *the command to launch your tests*

【讨论】:

    【解决方案3】:

    我在 Chrome 浏览器 55.0.2883.87、Chrome 驱动程序 2.27 上遇到了同样的问题 Selenium 3.0.1,作为作者:

    “org.openqa.selenium.SessionNotCreatedException: 无法创建新的远程会话。”

    之前 Grid 使用 Firefox 46.0.1、Selenium 2.52.0。 但我已将 Node 和 Hub Url 的位置切换为:

    driver = new RemoteWebDriver(hubAddress.toURL(), capabilities);
    

    它对我有用。 我希望这会对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-03
      • 2017-09-10
      • 2017-05-26
      • 2021-04-05
      • 2017-06-03
      • 1970-01-01
      • 2022-01-16
      • 2017-12-19
      相关资源
      最近更新 更多