- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
无论我尝试什么;最新的 chrome 浏览器、最新的 chromedriver、最新的 selenium 服务器等,但是当我在 Mac OSX 上运行测试时,我不断收到上述错误。我看过其他类似的问题,甚至尝试了那里建议的解决方案,但似乎没有什么对我有用。我错过了什么或做错了什么??
这是我的设置:
我正在初始化我的集线器和节点,如下所示
中心: java -jar selenium-server-standalone-3.141.59.jar -role hub -port 9999
节点: 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)
Selenium 集线器 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)
最佳答案
将节点命令更改为如下所示,并指定 chromedriver.exe 的路径和配置节点上可用插槽的 config.json 文件:
java -Dwebdriver.chrome.driver="C:\Users\xxxx\Documents\Browsers\ChromeDirectory\chromedriver.exe" -jar selenium-server-standalone-3.141.59.jar -role node -hub "http://XX.XXX.XX.XXX:4444/grid/register/" -nodeConfig config.json
关于java - 不断收到 SessionNotCreatedException : Unable to create new service: ChromeDriverService error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56854432/
我们在 org.openqa.selenium.chrome 中提供了 ChromeDriverService 类... 我知道这将有助于使用以下代码在机器的任何端口上启动 chrome 驱动程序..
我们有 AngularJS Protractor 测试。该过程是按顺序设置并运行这些步骤: $ npm install $ webdriver-manager update --ie32 --igno
我正在尝试在我的 Windows 10 计算机上运行 webdriverio,并且在尝试运行我的测试 js 文件时一直遇到同样的问题。所以我运行这个 -jar/your/download/direct
无论我尝试什么;最新的 chrome 浏览器、最新的 chromedriver、最新的 selenium 服务器等,但是当我在 Mac OSX 上运行测试时,我不断收到上述错误。我看过其他类似的问题,
我的代码如下: ChromeDriverService service = new ChromeDriverService.Builder() .usingChromeDriverExecuta
这是我的代码,我无法创建节点,并且它抛出异常 FAILED: runtestorg.openqa.selenium.SessionNotCreatedException:无法创建新服务:ChromeD
我已经在我的本地计算机上设置了 Selenium Grid(集线器和节点),该计算机在 Windows 10 上运行,使用以下命令注册集线器。 java -jar selenium-server-st
我正在尝试使用 facebook php-webdriver 设置 Selenium。这就是我所做的: Ran composer 需要 facebook/webdriver 来安装包 在端口 4444
嗨,任何人都知道发生了什么,或者我如何调试错误,如下所示。我所做的步骤是使用 setup hub 命令并将节点注册到集线器。在命令寄存器节点之后。我可以看到日志为 The node is regist
chromedriver-version: 79.0.3945.36 google-chrome version:79.0.3945.88 java version:openjdk version "
Python 3.7.3 Pycharm 2019.1.3 Selenium 独立3.14.0 Selenium 3.141.0 Java JDK 12.0.2 Windows 7 当我尝试使用远程网
我是一名优秀的程序员,十分优秀!