无论我尝试什么;最新的chrome浏览器,最新的chromedriver,最新的selenium服务器,等等。但是当我在Mac OSX上运行测试时,我不断得到上面的错误。我研究过其他类似的问题,甚至尝试过那里提出的解决方案,但似乎没有任何效果。我错过了什么或做错了什么??
以下是我的设置:
我正在初始化我的集线器和节点,如下所示
java-jarselenium-server-standalone-3.141.59.jar角色集线器端口9999
节点:java-jar-selenium-server-standalone-3.141.59。jar-角色节点-中心http://localhost:9999/grid/register
下面是我初始化远程WebDriver实例的方式。
java prettyprint-override">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 hub withdebug
标志在我尝试运行测试失败后显示以下内容
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)
更改node命令,使其与chromedriver的路径类似。exe和配置文件。配置节点上可用插槽的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
我知道这个问题以前被问过多次,但没有一个解决方案对我有帮助。 3个月前,我成功地做到了这一点,但现在我陷入了困境,没有改变任何让我困惑的事情,我真的不知道该怎么办! 1:基本信息:win 7 Rselenium standalone 3.13.0(试用过3.9.1,但不起作用,三个月前就开始工作了)chrome版本v64。0.3282.140(32位)chromedriver 2.37应兼容。(还
问题内容: 嗨,任何人都知道这是怎么回事或如何调试以下错误。我所做的步骤是使用安装中心命令并将节点注册到中心。在命令注册节点之后。我可以看到日志为 但是,当我运行测试脚本时,出现以下错误: 二进制版本: selenium独立版本:3.14.0 selenium远程驱动程序版本:selenium== 3.14.1 python版本:3.6.4 脚本: 设置中心: 注册节点: 错误: 问题答案: 此错
问题内容: 我无法使用geckodriver从Selenium驱动Firefox。这很奇怪,因为chrome是由相同的框架驱动的,没有错误! 这些是我的版本号: 我使用Java从Selenium Webdriver获得的错误如下: 这是我的设置,Firefox坏了,chrome可以了: Grid_SetUp.java selenium_grid.sh: execute_grid.sh: 我现在更新
> 首先将在后台启动google chrome无头: google-chrome--无头--无沙箱--无缓存--禁用GPU--禁用Dev-SHM-用法& 然后启动ChromeDriver: ChromeDriver--Proxy-Server=10.0.x.x:yyyy--headless--disable-GPU--nogui--no-sandbox--enable-logging--ignor
有人能帮我吗?我是Android系统的新手,我正尝试在AVD中打开应用程序,安装了应用程序,但我得到错误“一个新的会话不能被创建。(原始错误:命令失败:)”,“杀死”:false,“代码”:1,“信号”:null,“origvalue”:“命令失败:”},“sessionid”:null} 谢谢你事先的帮助 尝试只提供Capabilities.SetCapability(“AppActivity”
我已经执行了selenium-server-standalone-3.141.59。jar在我的本地机器上,当我试图在下面“创建会话”时,Chrome浏览器中显示了一个错误。 这就是我如何在CMD推出selenium-server-standalone-3.141.59.jar