macOS:版本 10.13.4
Safari:版本 11.1
Selenium-standalone:版本:6.14.1
摘要:在通过 SSH 启动的 selenium-standalone 实例上运行自动化时,驱动程序日志中出现“无法建立新会话”。
注意:如果您在没有 SSH 的情况下直接在 mac 机器上启动 selenium-standalone,则一切正常
重现步骤:
1) 通过 SSH 连接到 mac 设备。
2) 启动 selenium-standalone
命令: selenium-standalone start -- -role node -nodeConfig safari.json
safari.json:
{
"capabilities":
[
{
"browserName": "safari",
"platform": "MAC",
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 1,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "http://ReplaceWithHubUrl:4449",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"host":"ReplacewithNodeIP",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
3)运行自动化(当然指向集线器)
硒服务器日志:
12:12:41.490 INFO - Selenium build info: version: '3.8.1', revision: '6e95a6684b'
12:12:41.491 INFO - Launching a Selenium Grid node
2018-05-24 12:12:44.846:INFO::main: Logging initialized @3650ms to org.seleniumhq.jetty9.util.log.StdErrLog
12:12:44.871 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
12:12:44.877 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
12:12:44.879 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
12:12:44.879 INFO - Driver class not found: com.opera.core.systems.OperaDriver
12:12:44.879 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
12:12:44.880 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
12:12:44.880 INFO - Driver class not found: org.openqa.selenium.phantomjs.PhantomJSDriver
12:12:44.890 INFO - Driver provider class org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities {browserName: internet explorer, ensureCleanSession: true, platform: WINDOWS, version: } does not match the current platform MAC
12:12:44.890 INFO - Driver provider class org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities {browserName: MicrosoftEdge, platform: WINDOWS, version: } does not match the current platform MAC
12:12:44.911 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
12:12:44.911 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
12:12:44.911 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
12:12:44.912 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
12:12:44.912 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
12:12:44.917 INFO - Using the passthrough mode handler
2018-05-24 12:12:44.934:INFO:osjs.Server:main: jetty-9.4.7.v20170914
2018-05-24 12:12:44.950:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@ba54932{/,null,STARTING} has uncovered http methods for path: /
2018-05-24 12:12:44.953:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@ba54932{/,null,AVAILABLE}
2018-05-24 12:12:44.971:INFO:osjs.AbstractConnector:main: Started ServerConnector@d6e7bab{HTTP/1.1,[http/1.1]}{0.0.0.0:5555}
2018-05-24 12:12:44.971:INFO:osjs.Server:main: Started @3775ms
12:12:44.971 INFO - Selenium Grid node is up and ready to register to the hub
12:12:44.976 INFO - Starting auto registration thread. Will try to register every 5000 ms.
12:12:44.976 INFO - Registering the node to the hub: http://qa-docker02.avirat.net:4449/grid/register
12:12:44.987 INFO - The node is registered to the hub and ready to use
Selenium started
2018-05-24 12:12:49.235:INFO:osjshC.ROOT:qtp782378927-10: org.openqa.selenium.remote.server.WebDriverServlet-5e5d171f: Initialising WebDriverServlet
12:12:49.249 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@5452a53c
12:12:49.251 INFO - /session: Executing POST on /session (handler: BeginSession)
12:12:49.295 INFO - Capabilities are: Capabilities {browserName: safari}
12:12:49.297 INFO - Capabilities {browserName: safari} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.safari.SafariDriverService)
驱动日志:
org.openqa.selenium.SessionNotCreatedException: Cannot establish new session
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'qa01.avirat.net', ip: 'fe80:0:0:0:1854:3678:a42:3622%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_121'
Driver info: driver.version: unknown
Command duration or timeout: 52.01 seconds
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$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
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:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:132)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:145)
at cucumber.driver.Factory.createDriver(Factory.java:29)
at cucumber.support.Hooks.beforeScenario(Hooks.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at cucumber.runtime.Utils$1.call(Utils.java:31)
at cucumber.runtime.Timeout.timeout(Timeout.java:16)
at cucumber.runtime.Utils.invoke(Utils.java:25)
at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:60)
at cucumber.runtime.HookDefinitionMatch.runStep(HookDefinitionMatch.java:17)
at cucumber.runner.UnskipableStep.executeStep(UnskipableStep.java:22)
at cucumber.api.TestStep.run(TestStep.java:83)
at cucumber.api.TestCase.run(TestCase.java:58)
at cucumber.runner.Runner.runPickle(Runner.java:80)
at cucumber.runtime.Runtime.runFeature(Runtime.java:119)
at cucumber.runtime.Runtime.run(Runtime.java:104)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)
Selenium Hub 日志
starting selenium hub with configuration:
{
"host": null,
"port": 4444,
"role": "hub",
"maxSession": 50,
"newSessionWaitTimeout": 120000,
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"jettyMaxThreads": -1,
"cleanUpCycle": 60000,
"browserTimeout": 60000,
"timeout": 90000,
"debug": false
}
19:33:36.875 INFO - Selenium build info: version: '3.7.1', revision: '8a0099a'
19:33:36.878 INFO - Launching Selenium Grid hub
2018-05-24 19:33:37.883:INFO::main: Logging initialized @2333ms to org.seleniumhq.jetty9.util.log.StdErrLog
19:33:37.914 INFO - Will listen on 4444
2018-05-24 19:33:38.014:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2018-05-24 19:33:38.081:INFO:osjs.session:main: DefaultSessionIdManager workerName=node0
2018-05-24 19:33:38.081:INFO:osjs.session:main: No SessionScavenger set, using defaults
2018-05-24 19:33:38.089:INFO:osjs.session:main: Scavenging every 600000ms
2018-05-24 19:33:38.107:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@57d5872c{/,null,AVAILABLE}
2018-05-24 19:33:38.154:INFO:osjs.AbstractConnector:main: Started ServerConnector@1f1c7bf6{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2018-05-24 19:33:38.155:INFO:osjs.Server:main: Started @2605ms
19:33:38.155 INFO - Nodes should register to http://10.255.1.238:4444/grid/register/
19:33:38.155 INFO - Selenium Grid hub is up and running
19:33:39.082 INFO - Registered a node http://10.57.85.10:5555
19:34:08.364 INFO - Got a request to create a new session: Capabilities {browserName: safari}
19:34:08.365 INFO - Trying to create a new session on test slot {seleniumProtocol=WebDriver, technologyPreview=false, se:CONFIG_UUID=c82e2553-dfdf-409c-8028-c76da8352368, browserName=safari, maxInstances=1, platform=MAC}