Selenium Grid (Java) 无法与新的 Windows 终端一起正常工作
Selenium Grid (Java) does not work correctly with new Windows Terminal
我们在我们的项目中使用 Selenium (Java) 进行测试,并且我们成功地拥有了 Selenium Grid(基本上是各种浏览器的集线器)运行ning。
用于 Windows CLI 的 运行ning Selenium Grid 的脚本是这个,存储在 .bat 文件中:
start java -jar selenium-server-standalone-3.141.59.jar -role hub
start java -Dwebdriver.chrome.driver="D:\drivers\chromedriver.exe" -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://localhost:4444/grid/register -port 4546
start java -Dwebdriver.ie.driver="D:\drivers\IEDriverServer.exe" -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://localhost:4444/grid/register -port 4547
此脚本一直有效,但它在 windows 中有 3 个单独的 windows,有点笨拙。
最近,Windows 发布了 Windows 终端 (WT) - 其新功能之一是 运行 在一个 window 中选择多个选项卡。因此,我将以前的脚本重写为使用 Windows 终端的脚本,这样我的任务栏就不会乱七八糟了,它看起来像这样:
wt -d d:\Programs\SeleniumStandaloneServer\ java -jar selenium-server-standalone-3.141.59.jar -role hub; sp -d d:\Programs\SeleniumStandaloneServer\ java -Dwebdriver.chrome.driver='D:\drivers\chromedriver.exe' -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://localhost:4444/grid/register -port 4546; sp -H -d d:\Programs\HIE\SeleniumStandaloneServer\ java -Dwebdriver.ie.driver='D:\drivers\IEDriverServer.exe' -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://localhost:4444/grid/register -port 4547
问题是,每当我 运行 这个 WT 脚本而不是前一个时,它只能每隔一秒工作一次。
在你问之前,是的,我用记事本++检查了转录后字母的差异或可能不需要的空格,人为错误 - 脚本本身没问题。
前一个脚本每次都有效(每次启动浏览器并且我们的测试正确完成),这个脚本每秒(偶数)次都有效,每个第一个(奇数)它都会在中留下错误消息我们的 IntteliJ 控制台:
有人可以帮我解决这个问题吗?我不知道哪里出了问题。
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'DESKTOP-B4ED459', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.8'
Driver info: driver.version: unknown
Command duration or timeout: 185 milliseconds
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$errorHandler[=13=](JsonWireProtocolResponse.java:54)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction[=13=](HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession[=13=](ProtocolHandshake.java:126)
at java.base/java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at com.browsersoft.selenium.core.SeleniumRunner.run(SeleniumRunner.java:44)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1260)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:814)
at groovy.lang.GroovyObject.invokeMethod(GroovyObject.java:39)
at com.browsersoft.selenium.SeleniumManager.executeTest(SeleniumManager.java:42)
at com.browsersoft.config.core.scenario.Scenario.executeSeleniumStep(Scenario.java:223)
at com.browsersoft.config.core.scenario.Scenario.executeStep(Scenario.java:189)
at com.browsersoft.config.gui.document.scenario.ScenarioStepPanel.run(ScenarioStepPanel.java:224)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'DESKTOP-B4ED459', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.8'
Driver info: driver.version: unknown
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'DESKTOP-B4ED459', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.8'
Driver info: driver.version: unknown
at org.openqa.selenium.grid.session.remote.ServicedSession$Factory.lambda$get[=13=](ServicedSession.java:135)
at org.openqa.selenium.grid.session.remote.ServicedSession$Factory.apply(ServicedSession.java:152)
at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply(ActiveSessionFactory.java:180)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:442)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:177)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.server.ActiveSessionFactory.apply(ActiveSessionFactory.java:183)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$null(NewSessionPipeline.java:66)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:177)
at java.util.Collections.tryAdvance(Collections.java:4747)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession(NewSessionPipeline.java:69)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.util.stream.DistinctOps.accept(DistinctOps.java:175)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:177)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:177)
at java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:397)
at java.util.stream.Streams$ConcatSpliterator.tryAdvance(Streams.java:720)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.server.NewSessionPipeline.createNewSession(NewSessionPipeline.java:72)
at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute(BeginSession.java:65)
at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle[=13=](WebDriverServlet.java:235)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:834)
这是WT控制台windows失败后的内容运行:
16:09:30.589 INFO [GridLauncherV3.lambda$buildLaunchers] - Launching Selenium Grid hub on port 4444
2021-10-21 16:09:30.985:INFO::main: Logging initialized @744ms to org.seleniumhq.jetty9.util.log.StdErrLog
16:09:31.670 INFO [Hub.start] - Selenium Grid hub is up and running
16:09:31.672 INFO [Hub.start] - Nodes should register to http://172.30.1.4:4444/grid/register/
16:09:31.673 INFO [Hub.start] - Clients should connect to http://172.30.1.4:4444/wd/hub
16:09:32.615 INFO [DefaultGridRegistry.add] - Registered a node http://172.30.1.4:4546
16:09:32.616 INFO [DefaultGridRegistry.add] - Registered a node http://172.30.1.4:4547
16:10:32.120 INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, version: }
16:10:32.124 INFO [TestSlot.getNewSession] - Trying to create a new session on test slot {server:CONFIG_UUID=63e678db-5111-42b8-ba59-bb9780f21e47, seleniumProtocol=WebDriver, browserName=chrome, maxInstances=5, platformName=WIN10, platform=WIN10}
16:09:30.653 INFO [GridLauncherV3.lambda$buildLaunchers] - Launching a Selenium Grid node on port 4546
2021-10-21 16:09:31.510:INFO::main: Logging initialized @1210ms to org.seleniumhq.jetty9.util.log.StdErrLog
16:09:31.721 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
16:09:31.800 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4546
16:09:31.801 INFO [GridLauncherV3.lambda$buildLaunchers] - Selenium Grid node is up and ready to register to the hub
16:09:32.082 INFO [SelfRegisteringRemote.run] - Starting auto registration thread. Will try to register every 5000 ms.
16:09:32.341 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://localhost:4444/grid/register
16:09:32.616 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
16:10:32.191 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
],
"extensions": [
]
},
"version": ""
}
16:10:32.193 INFO [ActiveSessionFactory.lambda$apply] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
16:09:30.704 INFO [GridLauncherV3.lambda$buildLaunchers] - Launching a Selenium Grid node on port 4547
2021-10-21 16:09:31.577:INFO::main: Logging initialized @1216ms to org.seleniumhq.jetty9.util.log.StdErrLog
16:09:31.780 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
16:09:31.862 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4547
16:09:31.862 INFO [GridLauncherV3.lambda$buildLaunchers] - Selenium Grid node is up and ready to register to the hub
16:09:32.135 INFO [SelfRegisteringRemote.run] - Starting auto registration thread. Will try to register every 5000 ms.
16:09:32.340 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://localhost:4444/grid/register
16:09:32.616 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
所以我发现了问题所在并发布了答案以防其他人遇到类似问题:
事实证明,Selenium 或 Windows Terminal 没有任何问题,我们不得不开始使用最新稳定版本的 Selenium Grid(我们仍在使用 3.x.x 版本,因为它是唯一的一个支持了很长时间,直到最近才发布 4.x.x 版本)+更改脚本,因为 Selenium 开发人员决定更改版本之间的开关,因此旧脚本(发布在问题本身中)将不起作用,并且必须像这样更新:
@echo off
start java -jar selenium-server-standalone-4.1.1.jar hub
start java -Dwebdriver.chrome.driver="D:\drivers\chromedriver.exe" -jar selenium-server-standalone-4.1.1.jar node --hub http://localhost:4444/grid/register --port 4546
start java -Dwebdriver.ie.driver="D:\drivers\IEDriverServer.exe" -jar selenium-server-standalone-4.1.1.jar node --hub http://localhost:4444/grid/register --port 4547
Windows 终端也类似:
wt -d d:\Programs\SeleniumStandaloneServer\ java -jar selenium-server-standalone-4.1.1.jar hub; sp -d d:\Programs\SeleniumStandaloneServer\ java -Dwebdriver.chrome.driver="D:\drivers\chromedriver.exe" -jar selenium-server-standalone-4.1.1.jar node --hub http://localhost:4444/grid/register --port 4546; sp -H -d d:\Programs\SeleniumStandaloneServer\ java -Dwebdriver.ie.driver="D:\Praca\Automation\drivers\IEDriverServer.exe" -jar selenium-server-standalone-4.1.1.jar node --hub http://localhost:4444/grid/register --port 4547
现在网格可以与这两个脚本一起正常工作。
我们在我们的项目中使用 Selenium (Java) 进行测试,并且我们成功地拥有了 Selenium Grid(基本上是各种浏览器的集线器)运行ning。
用于 Windows CLI 的 运行ning Selenium Grid 的脚本是这个,存储在 .bat 文件中:
start java -jar selenium-server-standalone-3.141.59.jar -role hub
start java -Dwebdriver.chrome.driver="D:\drivers\chromedriver.exe" -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://localhost:4444/grid/register -port 4546
start java -Dwebdriver.ie.driver="D:\drivers\IEDriverServer.exe" -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://localhost:4444/grid/register -port 4547
此脚本一直有效,但它在 windows 中有 3 个单独的 windows,有点笨拙。
最近,Windows 发布了 Windows 终端 (WT) - 其新功能之一是 运行 在一个 window 中选择多个选项卡。因此,我将以前的脚本重写为使用 Windows 终端的脚本,这样我的任务栏就不会乱七八糟了,它看起来像这样:
wt -d d:\Programs\SeleniumStandaloneServer\ java -jar selenium-server-standalone-3.141.59.jar -role hub; sp -d d:\Programs\SeleniumStandaloneServer\ java -Dwebdriver.chrome.driver='D:\drivers\chromedriver.exe' -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://localhost:4444/grid/register -port 4546; sp -H -d d:\Programs\HIE\SeleniumStandaloneServer\ java -Dwebdriver.ie.driver='D:\drivers\IEDriverServer.exe' -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://localhost:4444/grid/register -port 4547
问题是,每当我 运行 这个 WT 脚本而不是前一个时,它只能每隔一秒工作一次。 在你问之前,是的,我用记事本++检查了转录后字母的差异或可能不需要的空格,人为错误 - 脚本本身没问题。
前一个脚本每次都有效(每次启动浏览器并且我们的测试正确完成),这个脚本每秒(偶数)次都有效,每个第一个(奇数)它都会在中留下错误消息我们的 IntteliJ 控制台:
有人可以帮我解决这个问题吗?我不知道哪里出了问题。
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'DESKTOP-B4ED459', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.8'
Driver info: driver.version: unknown
Command duration or timeout: 185 milliseconds
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$errorHandler[=13=](JsonWireProtocolResponse.java:54)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction[=13=](HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession[=13=](ProtocolHandshake.java:126)
at java.base/java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at com.browsersoft.selenium.core.SeleniumRunner.run(SeleniumRunner.java:44)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1260)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:814)
at groovy.lang.GroovyObject.invokeMethod(GroovyObject.java:39)
at com.browsersoft.selenium.SeleniumManager.executeTest(SeleniumManager.java:42)
at com.browsersoft.config.core.scenario.Scenario.executeSeleniumStep(Scenario.java:223)
at com.browsersoft.config.core.scenario.Scenario.executeStep(Scenario.java:189)
at com.browsersoft.config.gui.document.scenario.ScenarioStepPanel.run(ScenarioStepPanel.java:224)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'DESKTOP-B4ED459', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.8'
Driver info: driver.version: unknown
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'DESKTOP-B4ED459', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.8'
Driver info: driver.version: unknown
at org.openqa.selenium.grid.session.remote.ServicedSession$Factory.lambda$get[=13=](ServicedSession.java:135)
at org.openqa.selenium.grid.session.remote.ServicedSession$Factory.apply(ServicedSession.java:152)
at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply(ActiveSessionFactory.java:180)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:442)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:177)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.server.ActiveSessionFactory.apply(ActiveSessionFactory.java:183)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$null(NewSessionPipeline.java:66)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:177)
at java.util.Collections.tryAdvance(Collections.java:4747)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession(NewSessionPipeline.java:69)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.util.stream.DistinctOps.accept(DistinctOps.java:175)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:177)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:177)
at java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:397)
at java.util.stream.Streams$ConcatSpliterator.tryAdvance(Streams.java:720)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.server.NewSessionPipeline.createNewSession(NewSessionPipeline.java:72)
at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute(BeginSession.java:65)
at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle[=13=](WebDriverServlet.java:235)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:834)
这是WT控制台windows失败后的内容运行:
16:09:30.589 INFO [GridLauncherV3.lambda$buildLaunchers] - Launching Selenium Grid hub on port 4444
2021-10-21 16:09:30.985:INFO::main: Logging initialized @744ms to org.seleniumhq.jetty9.util.log.StdErrLog
16:09:31.670 INFO [Hub.start] - Selenium Grid hub is up and running
16:09:31.672 INFO [Hub.start] - Nodes should register to http://172.30.1.4:4444/grid/register/
16:09:31.673 INFO [Hub.start] - Clients should connect to http://172.30.1.4:4444/wd/hub
16:09:32.615 INFO [DefaultGridRegistry.add] - Registered a node http://172.30.1.4:4546
16:09:32.616 INFO [DefaultGridRegistry.add] - Registered a node http://172.30.1.4:4547
16:10:32.120 INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, version: }
16:10:32.124 INFO [TestSlot.getNewSession] - Trying to create a new session on test slot {server:CONFIG_UUID=63e678db-5111-42b8-ba59-bb9780f21e47, seleniumProtocol=WebDriver, browserName=chrome, maxInstances=5, platformName=WIN10, platform=WIN10}
16:09:30.653 INFO [GridLauncherV3.lambda$buildLaunchers] - Launching a Selenium Grid node on port 4546
2021-10-21 16:09:31.510:INFO::main: Logging initialized @1210ms to org.seleniumhq.jetty9.util.log.StdErrLog
16:09:31.721 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
16:09:31.800 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4546
16:09:31.801 INFO [GridLauncherV3.lambda$buildLaunchers] - Selenium Grid node is up and ready to register to the hub
16:09:32.082 INFO [SelfRegisteringRemote.run] - Starting auto registration thread. Will try to register every 5000 ms.
16:09:32.341 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://localhost:4444/grid/register
16:09:32.616 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
16:10:32.191 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
],
"extensions": [
]
},
"version": ""
}
16:10:32.193 INFO [ActiveSessionFactory.lambda$apply] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
16:09:30.704 INFO [GridLauncherV3.lambda$buildLaunchers] - Launching a Selenium Grid node on port 4547
2021-10-21 16:09:31.577:INFO::main: Logging initialized @1216ms to org.seleniumhq.jetty9.util.log.StdErrLog
16:09:31.780 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
16:09:31.862 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4547
16:09:31.862 INFO [GridLauncherV3.lambda$buildLaunchers] - Selenium Grid node is up and ready to register to the hub
16:09:32.135 INFO [SelfRegisteringRemote.run] - Starting auto registration thread. Will try to register every 5000 ms.
16:09:32.340 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://localhost:4444/grid/register
16:09:32.616 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
所以我发现了问题所在并发布了答案以防其他人遇到类似问题:
事实证明,Selenium 或 Windows Terminal 没有任何问题,我们不得不开始使用最新稳定版本的 Selenium Grid(我们仍在使用 3.x.x 版本,因为它是唯一的一个支持了很长时间,直到最近才发布 4.x.x 版本)+更改脚本,因为 Selenium 开发人员决定更改版本之间的开关,因此旧脚本(发布在问题本身中)将不起作用,并且必须像这样更新:
@echo off
start java -jar selenium-server-standalone-4.1.1.jar hub
start java -Dwebdriver.chrome.driver="D:\drivers\chromedriver.exe" -jar selenium-server-standalone-4.1.1.jar node --hub http://localhost:4444/grid/register --port 4546
start java -Dwebdriver.ie.driver="D:\drivers\IEDriverServer.exe" -jar selenium-server-standalone-4.1.1.jar node --hub http://localhost:4444/grid/register --port 4547
Windows 终端也类似:
wt -d d:\Programs\SeleniumStandaloneServer\ java -jar selenium-server-standalone-4.1.1.jar hub; sp -d d:\Programs\SeleniumStandaloneServer\ java -Dwebdriver.chrome.driver="D:\drivers\chromedriver.exe" -jar selenium-server-standalone-4.1.1.jar node --hub http://localhost:4444/grid/register --port 4546; sp -H -d d:\Programs\SeleniumStandaloneServer\ java -Dwebdriver.ie.driver="D:\Praca\Automation\drivers\IEDriverServer.exe" -jar selenium-server-standalone-4.1.1.jar node --hub http://localhost:4444/grid/register --port 4547
现在网格可以与这两个脚本一起正常工作。