appium / appium-docker-android

Appium Server setup to automate android testing on real devices
https://hub.docker.com/r/appium/
Other
589 stars 228 forks source link

io.appium.java_client.service.local.InvalidServerInstanceException: There is no installed nodes! #114

Closed arunkumar-muthusamy closed 5 years ago

arunkumar-muthusamy commented 5 years ago

Hi,

I'm getting following exception while initializing the new driver AndroidDriver<MobileElement> androidDriver = new AndroidDriver(new URL(deviceFarmUrl), capabilities);

Everything was working well until end of last month. We didn't change anything in our end (other than we had Jenkins upgrade recently). BTW, the containers are provisioned runtime by Jenkins on Kube.

I understand, It is not an appium issue. I'm posting this to get some help from community.

Please let me know if i'm missing anything

Error from Test:

io.appium.java_client.service.local.InvalidServerInstanceException: Invalid server instance exception has occured: There is no installed nodes! Please install node via NPM (https://www.npmjs.com/package/appium#using-node-js) or download and install Appium app (http://appium.io/downloads.html)
at io.appium.java_client.service.local.AppiumServiceBuilder.findNodeInCurrentFileSystem(AppiumServiceBuilder.java:184)
at io.appium.java_client.service.local.AppiumServiceBuilder.checkAppiumJS(AppiumServiceBuilder.java:345)
at io.appium.java_client.service.local.AppiumServiceBuilder.createArgs(AppiumServiceBuilder.java:425)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:358)
at io.appium.java_client.service.local.AppiumDriverLocalService.buildService(AppiumDriverLocalService.java:86)
...
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 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:40)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:489)
at org.testng.internal.thread.ThreadUtil$1.call(ThreadUtil.java:52)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: mesg: ttyname failed: Inappropriate ioctl for device
/usr/lib/node_modules

at io.appium.java_client.service.local.AppiumServiceBuilder.findNodeInCurrentFileSystem(AppiumServiceBuilder.java:185)
... 27 more

Inside the Container:

$ node -v
 v10.16.3

$ appium -v
 1.14.2

$ echo $PATH
 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
arunkumar-muthusamy commented 5 years ago

I solved it on my own. Providing the answer here for those land here from google search...

It seems in the appium java client, the default path for appium main.js is /usr/local/lib/node_modules/appium/build/lib/main.js. But in the appium-docker-android container, it is located in /usr/lib/node_modules/appium/build/lib/main.js.

So, to fix this. Initialize the AppiumServiceBuilder with the path to appiumJs. See the code example below,

AppiumServiceBuilder serviceBuilder = new AppiumServiceBuilder().withAppiumJS(new File("/usr/lib/node_modules/appium/build/lib/main.js"));
AppiumDriverLocalService appiumDriverLocalService = AppiumDriverLocalService.buildService(serviceBuilder);
mykola-mokhnach commented 5 years ago

This might a problem with docker image config. Java client tries to detect node modules root by executing bash -l get_path_to_default_node.sh script, which internally executes npm root -g command. So, if any of these commands does not return a correct result then it fails with the error above.

cc @budtmo

arunkumar-muthusamy commented 5 years ago

@mykola-mokhnach Thanks for the insight!