python - session 未创建异常 : Message: Unable to create new service: ChromeDriverService with ChromeDriver and SeleniumGrid through Python

标签 python selenium selenium-webdriver selenium-chromedriver selenium-grid

嗨,任何人都知道发生了什么,或者我如何调试错误,如下所示。我所做的步骤是使用 setup hub 命令并将节点注册到集线器。在命令寄存器节点之后。我可以看到日志为

The node is registered to the hub and ready to use 

但是,当我运行测试脚本时,错误打印为:

selenium.common.exceptions.SessionNotCreatedException: Message: Unable to create new service: ChromeDriverService

二进制版本:

  • selenium 独立版本:3.14.0
  • selenium远程驱动版本:selenium==3.14.1
  • python版本:3.6.4

脚本:

import os
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub',
                          desired_capabilities=DesiredCapabilities.CHROME)

设置中心:

#java -jar /Users/admin/selenium-server-standalone-3.14.0.jar -host localhost -role hub

注册节点:

#java -jar /Users/admin/selenium-server-standalone-3.14.0.jar -role node

错误:

E       selenium.common.exceptions.SessionNotCreatedException: Message: Unable to create new service: ChromeDriverService
E       Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
E       Driver info: driver.version: unknown
E       Stacktrace:
E           at org.openqa.selenium.remote.server.ServicedSession$Factory.lambda$get$0 (ServicedSession.java:134)
E           at org.openqa.selenium.remote.server.ServicedSession$Factory.apply (ServicedSession.java:151)
E           at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply$12 (ActiveSessionFactory.java:177)
E           at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:193)
...
E           at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
E           at java.util.concurrent.FutureTask.run (FutureTask.java:266)
E           at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
E           at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
E           at java.lang.Thread.run (Thread.java:745)

../lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py:242: SessionNotCreatedException

最佳答案

这个错误信息...

selenium.common.exceptions.SessionNotCreatedException: Message: Unable to create new service: ChromeDriverService

...暗示 ChromeDriver 无法启动/生成新的 ChromeDriverService

命令 和您使用的二进制文件版本之间的不兼容性 存在一些问题,如下所示:

  • 您的JDK 版本1.8.0_91,它非常古老
  • JDK 升级到最新级别 JDK 8u181 .
  • 要注册一个 Selenium Grid Hub,您需要使用以下命令:

    >java -jar /Users/admin/selenium-server-standalone-3.14.0.jar -role hub
    
  • 要为 ChromeDriverChrome 注册一个 Selenium Grid Node,您需要传递 ChromeDriver 的绝对路径 以及Registration URIKeyValue,如下所示:

    >java -Dwebdriver.chrome.driver=/path/to/chromedriver.exe -jar /Users/admin/selenium-server-standalone-3.14.0.jar -role node -hub http://<IP_GRID_HUB>:4444/grid/register
    
  • 我觉得你的代码块不错。

关于python - session 未创建异常 : Message: Unable to create new service: ChromeDriverService with ChromeDriver and SeleniumGrid through Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52827006/

相关文章:

python - Python 3 中的过滤对象错误

python - 如何查询具有一对一关系的对象

python - 使用 Selenium 和 Python 进行跨浏览器测试

java - 为什么我的机器人屏幕截图方法捕获黑屏?

java - 在月份下拉列表中选择值 - Selenium Webdriver

python 3 : does Pool keep the original order of data passed to map?

python - 如何比较 Pandas Python 2.7 中给定 DataFrame 中的两个单元格

asp.net-mvc - 在本地 Selenium 上运行的同一解决方案下对项目运行测试

java - 如何处理 selenium Xpath 中的条件

angularjs - 如何从 Protractor 中的 ng-repeat 获取值?