org.openqa.selenium.WebDriverException with Grid
Description
Hi, I have recently upgraded Appium Java Client to 6.1.0 from 5.0.0 and I have been running into this issue where it is not able to create session correctly with grid. I tried whole day to debug the problem but I have no idea what's going on.
I found a previous post from someone else who had same or similar issue as me but was closed without solution https://github.com/appium/java-client/issues/926
Environment
- Appium Java Client: 6.1.0
- Appium server version: 1.9.0
- Desktop OS/version used to run Appium if necessary: 1.9.0
- Node.js version: v10.9.0
- Mobile platform/version under test: 8.1.0
- Real device or emulator/simulator: Real devices
Details
So when I run the test with a single instance of Appium, my test runs fine but when I start the test with hub and node to do parallel testing, thats where I start getting issues after upgrading to 6.1.0.
Steps:
- Start hub: java -jar /workspace/test/src/AppiumTest/tools/selenium-server-standalone-3.13.0.jar -role hub -log /workspace/test/src/AppiumTest/logs/hub.log
- Start Appium: appium -p 4810 -bp 6000 --nodeconfig /workspace/test/src/AppiumTest/node/grid_4810.json --session-override -g /workspace/test/src/AppiumTest/logs/appium4810.log
- Run Test
This is the Node Config
{
"capabilities": [
{
"platformVersion": "8.1.0",
"maxInstances": 1
}
],
"configuration": {
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"cleanUpCycle": 2000,
"port": 4810,
"host": "127.0.0.1",
"browserTimeout": 180,
"maxSession": 1,
"hubHost": "127.0.0.1",
"registerCycle": 5000,
"hubPort": 4444,
"timeout": 30000,
"url": "http://127.0.0.1:4723/wd/hub",
"register": true
}
}
Hub and node will connect with the message
[java] [debug] [Appium] Appium successfully registered with the grid on http://127.0.0.1:4444
and when it tries to create session it throws the error
[java] org.openqa.selenium.WebDriverException: It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible
Ecxeption stacktraces
[java] org.openqa.selenium.WebDriverException: It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible
[java] Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
[java] System info: host: '6c4008a80bd8.ant.amazon.com', ip: '192.168.10.111', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_181'
[java] Driver info: driver.version: MobileDriver
[java] at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:195)
[java] at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:209)
[java] at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231)
[java] at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
[java] at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
[java] at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
[java] at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
[java] at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
[java] at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
[java] at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38)
[java] at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:84)
[java] at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:94)
[java] at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:93)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:498)
[java] at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
[java] at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
[java] at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
[java] at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
[java] at org.testng.TestRunner.beforeRun(TestRunner.java:641)
[java] at org.testng.TestRunner.run(TestRunner.java:609)
[java] at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
[java] at org.testng.SuiteRunner.access$000(SuiteRunner.java:37)
[java] at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:368)
[java] at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
[java] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[java] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[java] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[java] at java.lang.Thread.run(Thread.java:748)
[java] Caused by: java.lang.reflect.InvocationTargetException
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:498)
[java] at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:185)
[java] ... 43 more
[java] Caused by: org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities {appActivity: com.amazon.venezia.Launcher, appPackage: com.amazon.venezia, deviceName: doesntmatter, nativeWebScreenshot: true, newCommandTimeout: 600, noReset: true, platformName: android, platformVersion: 8.1.0, recreateChromeDriverSessions: false, udid: 00764c4011c8a80d}
[java] Command duration or timeout: 171 milliseconds
[java] Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
[java] System info: host: '6c4008a80bd8.ant.amazon.com', ip: '192.168.10.111', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_181'
[java] Driver info: driver.version: MobileSmaugDriver
[java] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[java] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[java] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[java] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[java] at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
[java] at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
[java] at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
[java] at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
[java] at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:122)
[java] at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
[java] at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
[java] at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
[java] at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
[java] at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
[java] at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
[java] at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
[java] at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[java] at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
[java] at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:125)
[java] ... 48 more
[java] Caused by: org.openqa.grid.common.exception.GridException: Error forwarding the new session cannot find : Capabilities {appActivity: com.amazon.venezia.Launcher, appPackage: com.amazon.venezia, deviceName: doesntmatter, nativeWebScreenshot: true, newCommandTimeout: 600, noReset: true, platformName: android, platformVersion: 8.1.0, recreateChromeDriverSessions: false, udid: 00764c4011c8a80d}
[java] at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:118)
[java] at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:86)
[java] at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:70)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
[java] at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:860)
[java] at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:535)
[java] at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
[java] at org.seleniumhq.jetty9.security.SecurityHandler.handle(SecurityHandler.java:548)
[java] at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
[java] at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
[java] at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
[java] at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
[java] at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
[java] at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
[java] at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:473)
[java] at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:1564)
[java] at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
[java] at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
[java] at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
[java] at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
[java] at org.seleniumhq.jetty9.server.Server.handle(Server.java:530)
[java] at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:347)
[java] at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:256)
[java] at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
[java] at org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:102)
[java] at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
[java] at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:247)
[java] at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
[java] at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
[java] at org.seleniumhq.jetty9.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:382)
[java] at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:708)
[java] at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:626)
[java] ... 1 more
Appium logs
2018-10-22 23:02:49:818 - info: [Appium] Welcome to Appium v1.9.0 (REV 6506d4c9968b9232ec30e0639b5fb1e164123ffc)
2018-10-22 23:02:49:820 - info: [Appium] Non-default server args:
2018-10-22 23:02:49:821 - info: [Appium] port: 4810
2018-10-22 23:02:49:821 - info: [Appium] bootstrapPort: 6000
2018-10-22 23:02:49:821 - info: [Appium] sessionOverride: true
2018-10-22 23:02:49:821 - info: [Appium] log: /workspace/test/src/AppiumTest/logs/appium4810.log
2018-10-22 23:02:49:821 - info: [Appium] nodeconfig: /workspace/test/src/AppiumTest/node/grid_4810.json
2018-10-22 23:02:49:860 - info: [debug] [Appium] Starting auto register thread for grid. Will try to register every 5000 ms.
2018-10-22 23:02:49:861 - info: [Appium] Appium REST http interface listener started on 0.0.0.0:4810
2018-10-22 23:02:54:972 - info: [debug] [Appium] Appium successfully registered with the grid on http://127.0.0.1:4444
2018-10-22 23:03:00:192 - info: [HTTP] --> GET /wd/hub/status
2018-10-22 23:03:00:192 - info: [HTTP] {}
2018-10-22 23:03:00:193 - info: [debug] [MJSONWP] Calling AppiumDriver.getStatus() with args: []
2018-10-22 23:03:00:197 - error: uncaughtException: write EPIPE date=Mon Oct 22 2018 16:03:00 GMT-0700 (Pacific Daylight Time), pid=36670, uid=462297990, gid=1896053708, cwd=/workspace/test/src/AppiumTest, execPath=/Users/kwanglee/.nvm/versions/node/v10.9.0/bin/node, version=v10.9.0, argv=[/Users/kwanglee/.nvm/versions/node/v10.9.0/bin/node, /Users/kwanglee/.nvm/versions/node/v10.9.0/bin/appium, -p, 4810, -bp, 6000, --nodeconfig, /workspace/test/src/AppiumTest/node/grid_4810.json, --session-override, -g, /workspace/test/src/AppiumTest/logs/appium4810.log], rss=143851520, heapTotal=118018048, heapUsed=82045648, external=1370553, loadavg=[3.58251953125, 2.99267578125, 3.33349609375], uptime=7944, trace=[column=14, file=net.js, function=WriteWrap.afterWrite, line=836, method=afterWrite, native=false], stack=[Error: write EPIPE, at WriteWrap.afterWrite (net.js:836:14)]
But when I run the same code with the following steps, it works fine.
- Start appium: appium
- Run Test
Let me know if I missed anything, its my first time posting a question and would appreciate any help I can get
One way I could get around this issue is by using one instance of appium and using different systemPort as capabilities instead of using hub and nodes.
Before when I was using AppiumJavaClient 5.0.0 + appium 1.7.1, I had problems where there were times i would get an android boostrap error intermittently where I think it was happening due to only one instance of appium running.
Now that I upgraded appium, i will try test around with using systemPorts again until this issue gets resolved.
Used 6.0.0BETA4 and I am able to run the test on Grid. I see that there is work for "better handling of invocationtargetexception" in 7.0.0 so will close this and try it out once 7.0.0 comes out