首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >无法使用chromedriver创建新的远程会话

无法使用chromedriver创建新的远程会话
EN

Stack Overflow用户
提问于 2016-11-08 16:44:37
回答 2查看 16.8K关注 0票数 2

我之前使用的是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非常陌生,非常感谢任何人的帮助。

升级后的错误

代码语言:javascript
复制
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)

-----UPDATE

在对webdriver url进行了更改后,它看起来像是启动了,但现在我得到了另一个抛出的错误。

代码语言:javascript
复制
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)
EN

回答 2

Stack Overflow用户

发布于 2016-11-09 00:44:09

如果你能让我们知道你的Chrome浏览器版本是什么,这将会有很大的帮助,因为它会显著影响ChromeDriver的兼容性。例如,如果你意外地更新到了Chrome浏览器的54版本,那么你很可能需要ChromeDriver 2.25才能正常工作。

只要你说它在你之前的设置下工作;,我会把我的钱押在你实际的Chrome浏览器(小心,不是chromeDriver)更新上,就在你的鼻子底下;因此导致了这个错误。整个组合:

  • Selenium Standalone

  • ChromeDriver

  • Chrome Browser

在更改时非常脆弱(出于这个原因,我个人强制我的浏览器不自动更新)。如果你想强制Chrome浏览器更新,而不是,只需转到Chrome路径,并将更新文件夹重命名为update_old (规范的win路径: C:\Program Files (X86)\Google\)。这将禁止Chrome进行任何进一步的自动更新。

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

如果这还不能解决你的问题,那么尝试使用不同版本的Chrome + ChromeDriver,直到你得到正确的结果。Selenium不太容易更改,3.0.1版应该可以根据您的需要与任何组合一起使用。看看这里,看看哪些版本的ChromeDriver与哪些版本的Chrome浏览器兼容。

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

  • Chrome Browser 54.0.2840.87 (撰写本文时的最新版本)
  • Chrome Driver 2.25
  • Selenium 3.0.1

祝你好运!

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

正如我在下面的评论中提到的,我的选项100%适用于最新版本的Chrome (54.0),ChromeDriver (2.25)和Selenium (3.0.1).You可以首先尝试注释所有功能,并使用这些选项运行chrome:

代码语言:javascript
复制
    System.setProperty("webdriver.chrome.driver", "C:\\projects\\test\\chromedriver.exe");
            ChromeOptions options = new ChromeOptions();  
            options.addArguments("test-type");
            options.addArguments("--disable-extensions");

因此,您可以使用以下命令激活上面的命令:

代码语言:javascript
复制
driver = new ChromeDriver(options);

关于功能,我认为您正在使用的版本one没有获得或传达一个值。如果你坚持使用它(我个人觉得它毫无意义),你可以像下面这样指定一个值,看看这对你是否有效。

代码语言:javascript
复制
caps.setCapability("browser_version", "54.0.2840.87");

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

来自here

  • Chrome Driver (2.9)的here

  • Selenium 3.0.1

  • Chrome (48.0.2564.97)

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

票数 2
EN

Stack Overflow用户

发布于 2016-11-09 00:22:28

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

我被这个错误困扰了一段时间,通过在高级终端应用程序设置中取消选中“在启动时设置区域环境变量”复选框,我设法修复了这个问题。或者尝试使用以下前缀启动测试:

代码语言:javascript
复制
LC_NUMERIC=”en_US.UTF-8″ *the command to launch your tests*
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40482448

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档