Неважно, что я пытаюсь; последний браузер chrome, последний chromedriver, последний сервер selenium и т. д., но когда я запускаю тест на Mac OSX, я продолжаю получать вышеуказанную ошибку. Я смотрел на другие подобные вопросы и даже пробовал решения, предложенные там, но мне кажется, что ничего не получается. Что я пропускаю или делаю неправильно ??
Вот мои настройки:
- Chrome Версия: 75.0.3770.100 (последняя сборка)
- Chromedriver Версия: 75.0.3770.90 также пробовал 76
- Selenium Server Автономная версия: 3.141.59
- Java JDK Версия: 1.8.0_131
Я инициализирую свой концентратор и узел следующим образом
Hub:
java -jar selenium-server-standalone-3.141.59.jar -role hub -port 9999
Node:
java -jar selenium-server-standalone-3.141.59.jar -role node -hub http://localhost:9999/grid/register
Вот как я инициализирую свой экземпляр remoteWebDriver.
String absolutePath = Config.TEST_RESOURCES_PATH;
if(Platform.isWin()){
absolutePath = absolutePath + "chromedriver.exe"; // "C:\user\...\src\test\resources\chromedriver.exe"
} else if (Platform.isMac()){
absolutePath = absolutePath + "chromedriver";// "/Users/.../src/test/resources/chromedriver"
}
System.setProperty("webdriver.chrome.driver", absolutePath);
ChromeOptions cap = new ChromeOptions();
cap.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
String url = "http://" + Config.MACHINE_IP + ":" + Config.WEB_PORT_NUMBER + "/wd/hub";
try {
DriverAgent.setWebDriver(new RemoteWebDriver(new URL(url), cap));
} catch (MalformedURLException e) {
e.printStackTrace();
}
Когда я запускаю этот код на машине с Windows 10, он работает отлично, то есть открывается браузер и тесты проходят гладко; однако на компьютере Mac происходит сбой со следующим сообщением трассировки стека
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: 'xxx', ip: 'xxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.5', java.version: '1.8.0_131'
Driver info: driver.version: unknown
Command duration or timeout: 127 milliseconds
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
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$0(JsonWireProtocolResponse.java:54)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
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.automation.core.driver.DriverFactory.webDriverInit(DriverFactory.java:35)
at com.automation.test.listeners.TestListeners.onTestStart(TestListeners.java:77)
at org.testng.internal.Invoker.runTestListeners(Invoker.java:1904)
at org.testng.internal.Invoker.runTestListeners(Invoker.java:1879)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:685)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
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: 'xxx', ip: 'xxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.5', java.version: '1.8.0_131'
Driver info: driver.version: unknown
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'xxx', ip: 'xxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.5', java.version: '1.8.0_131'
Driver info: driver.version: unknown
at org.openqa.selenium.grid.session.remote.ServicedSession$Factory.lambda$get$0(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$12(ActiveSessionFactory.java:180)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:373)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.server.ActiveSessionFactory.apply(ActiveSessionFactory.java:183)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$null$2(NewSessionPipeline.java:66)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Collections$2.tryAdvance(Collections.java:4717)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession$3(NewSessionPipeline.java:69)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.DistinctOps$1$2.accept(DistinctOps.java:175)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:405)
at java.util.stream.Streams$ConcatSpliterator.tryAdvance(Streams.java:728)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
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$0(WebDriverServlet.java:235)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Концентратор селена с флагом debug
показывает следующее, как только я пытаюсь запустить тест, и он не проходит
12:41:19.848 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
12:41:19.930 INFO [GridLauncherV3.lambda$buildLaunchers$5] - Launching Selenium Grid hub on port 9999
2019-07-02 12:41:20.291:INFO::main: Logging initialized @648ms to org.seleniumhq.jetty9.util.log.StdErrLog
12:41:20.445 INFO [Hub.start] - Selenium Grid hub is up and running
12:41:20.445 INFO [Hub.start] - Nodes should register to http://<ip>:9999/grid/register/
12:41:20.446 INFO [Hub.start] - Clients should connect to http://<ip>:9999/wd/hub
12:41:25.521 DEBUG [RegistrationServlet.process] - getting the following registration request : {
"class": "org.openqa.grid.common.RegistrationRequest",
"configuration": {
"browserTimeout": 0,
"capabilities": [
{
"browserName": "firefox",
"marionette": true,
"maxInstances": 5,
"platform": "MAC",
"platformName": "MAC",
"seleniumProtocol": "WebDriver",
"server:CONFIG_UUID": "7d957d2e-e91a-40ea-aa49-2090126a7e50"
},
{
"browserName": "chrome",
"maxInstances": 5,
"platform": "MAC",
"platformName": "MAC",
"seleniumProtocol": "WebDriver",
"server:CONFIG_UUID": "724f2847-bd46-43cb-8952-7f3aa19a70e5"
},
{
"browserName": "safari",
"maxInstances": 1,
"platform": "MAC",
"platformName": "MAC",
"seleniumProtocol": "WebDriver",
"server:CONFIG_UUID": "c4faf8a4-6ff6-4df2-966e-4cbab352a3b6",
"technologyPreview": false
}
],
"custom": {
},
"debug": false,
"downPollingLimit": 2,
"enablePlatformVerification": true,
"host": "10.51.126.109",
"hub": "http:\u002f\u002flocalhost:9999\u002fgrid\u002fregister",
"id": "http:\u002f\u002f<ip>:48957",
"maxSession": 5,
"nodePolling": 5000,
"nodeStatusCheckTimeout": 5000,
"port": 48957,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"register": true,
"registerCycle": 5000,
"remoteHost": "http:\u002f\u002f<ip>:48957",
"role": "node",
"servlets": [
],
"timeout": 1800,
"unregisterIfStillDownAfter": 60000,
"withoutServlets": [
]
},
"description": null,
"name": null
}
12:41:25.545 DEBUG [BaseRemoteProxy.getNewInstance] - Using class org.openqa.grid.selenium.proxy.DefaultRemoteProxy
12:41:25.550 DEBUG [BaseRemoteProxy.setupTimeoutListener] - starting cleanup thread
12:41:25.551 DEBUG [BaseRemoteProxy$CleanUpThread.run] - cleanup thread starting...
12:41:25.552 INFO [DefaultGridRegistry.add] - Registered a node http://<ip>:48957
12:41:25.553 DEBUG [RegistrationServlet.lambda$process$0] - proxy added http://<ip>:48957
12:42:15.029 INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, takesScreenshot: true}
12:42:15.031 DEBUG [ProxySet.getNewSession] - Available nodes: [http://<ip>:48957]
12:42:15.032 DEBUG [BaseRemoteProxy.getNewSession] - Trying to create a new session on node http://<ip>:48957
12:42:15.032 INFO [TestSlot.getNewSession] - Trying to create a new session on test slot {server:CONFIG_UUID=724f2847-bd46-43cb-8952-7f3aa19a70e5, seleniumProtocol=WebDriver, browserName=chrome, maxInstances=5, platformName=MAC, platform=MAC}
И консоль узла показывает:
java -jar selenium-server-standalone-3.141.59.jar -role node -hub http://localhost:9999/grid/register
12:41:24.746 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
12:41:24.848 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Launching a Selenium Grid node on port 48957
2019-07-02 12:41:24.918:INFO::main: Logging initialized @379ms to org.seleniumhq.jetty9.util.log.StdErrLog
12:41:25.102 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
12:41:25.179 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 48957
12:41:25.179 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Selenium Grid node is up and ready to register to the hub
12:41:25.210 INFO [SelfRegisteringRemote$1.run] - Starting auto registration thread. Will try to register every 5000 ms.
12:41:25.509 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://localhost:9999/grid/register
12:41:25.552 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
12:42:15.100 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
],
"extensions": [
]
},
"takesScreenshot": true
}
12:42:15.102 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)