嗨,任何人都知道这是怎么回事或如何调试以下错误。我所做的步骤是使用安装中心命令并将节点注册到中心。在命令注册节点之后。我可以看到日志为
The node is registered to the hub and ready to use
但是,当我运行测试脚本时,我将错误打印为:
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to create new service: ChromeDriverService
二进制版本:
脚本:
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
答案 0 :(得分:1)
此错误消息...
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to create new service: ChromeDriverService
...表示 ChromeDriver 无法启动/产生新的 ChromeDriverService 。
正在使用的二进制版本之间,在命令和不兼容中存在两个问题:
要注册 Selenium Grid Hub ,您需要使用以下命令:
>java -jar /Users/admin/selenium-server-standalone-3.14.0.jar -role hub
要为 ChromeDriver 和 Chrome 注册 Selenium Grid节点,您需要传递 ChromeDriver的绝对路径以及注册URI 的 Key 和 Value ,如下所示:
>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
您的代码块对我来说很好。