Repository navigation
Unable to run Appium server programmatically #252
Description
@TikhomirovSergey as you suggested in the previous post i have my node set in Mac OSX path
➜ AppiumParallel git:(master) ✗ node --version
v0.12.7
echo $PATH
/Users/saikrisv/Library/Android/sdk/platform-tools:/Users/saikrisv/Library/Android/sdk/tools:/Users/saikrisv/Library/Android/sdk/platform-tools:/Users/saikrisv/Library/Android/sdk/tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I able to run node command from any path from ma commandline. Below is the code i use to start the server
AppiumServiceBuilder builder = new AppiumServiceBuilder().withAppiumJS(new File("/usr/local/lib/node_modules/appium/bin/appium.js"))
.withArgument(GeneralServerFlag.APP,
System.getProperty("user.dir") + "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/build/wordpress.apk")
.withArgument(GeneralServerFlag.LOG_LEVEL, "info").usingAnyFreePort(); /and so on/;
AppiumDriverLocalService service = builder.build();
service.start();
Error :::
io.appium.java_client.service.local.InvalidNodeJSInstance: Node.js is not installed
at io.appium.java_client.service.local.AppiumServiceBuilder.validateNodeJSVersion(AppiumServiceBuilder.java:87)
at io.appium.java_client.service.local.AppiumServiceBuilder.findDefaultExecutable(AppiumServiceBuilder.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:290)
at com.appium.android.test.AndriodTest.setUp(AndriodTest.java:45)
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:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.io.IOException: Cannot run program "node": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
at io.appium.java_client.service.local.AppiumServiceBuilder.validateNodeJSVersion(AppiumServiceBuilder.java:83)
... 27 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.(UNIXProcess.java:248)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 31 more
java.lang.NullPointerException
at com.appium.android.test.AndriodTest.tearDown(AndriodTest.java:58)
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:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Activity
TikhomirovSergey commentedon Oct 1, 2015
Hi @saikrishna321
There is really interesting situation
Are you starting it from the Eclipse for Mac OS?
This code works when I start it from IntelijIDEA/Eclipse for Windows (7&8). When I do the same from IntelijIDEA/Eclipse for Mac OS X it works with IntelijIDEA (I use v14.x).
With Eclipse for Mac OS I catch the same exception (!!!).
So I have two concerns:
@saikrishna321 If you know which settings should be defined please post them here. Also I recommend you to use IntelijIDEA till the root cause is found or use the following method:
Anyway everything should work with Maven started from a command line.
TikhomirovSergey commentedon Oct 3, 2015
It is the problem of Eclipse for Mac OS. As soon as possible I'll post the way to resolve the problem
TikhomirovSergey commentedon Oct 4, 2015
@saikrishna321
So
As I've mentioned it is the problem of Eclipse IDE (for Mac OS, it is probably for Linux too). Links:
... and tons of information that Google can find.
Actually I've tried some of these solutions:
This value was copied from output of
The same works with this samples.
So I can advice you a few ways to resolve your problem with the test debugging:
To configure Eclipse IDE/current project workspace properly
To use IntellijIDEA instead of Eclipse
To not do something special and set a full path to the certain Node.js instance
@saikrishna321 I'm waiting for your response. If you are agree then I'll close this ticket. Please provide some more details or describe your ideas otherwise.
saikrishna321 commentedon Oct 5, 2015
@TikhomirovSergey Thanks a lot for all the details and helping me out resolve this issue.
Is possible to set different bootstrap-port, the way we set appium_port ?
new AppiumServiceBuilder().
usingPort(4000);
TikhomirovSergey commentedon Oct 5, 2015
@saikrishna321 Yep
Then I'll close this issue. Actually I haven't known about this special thing of Eclipse IDE too :). Thanks! This ticket is marked by lables and information won't be lost.
pr4bh4sh commentedon Oct 6, 2015
The issue is marked closed now however i have the solution which works perfectly for me without using any configuration in eclipse at all.
I have cooked something using the below link prior to the autolaunch introduced in Java client itself.
http://stackoverflow.com/questions/20922600/execute-adb-command-from-java-program
@TikhomirovSergey it would be time saver if this could be integrated with java client.
TikhomirovSergey commentedon Oct 7, 2015
@pr4bh4sh
Thanks! I'll try this. If everithing is fine I'll propose a fix.
saikrishna321 commentedon Oct 8, 2015
@TikhomirovSergey to trigger the test in parallel i must pass the android device serial as well UDID.
How can i pass this ?
saikrishna321 commentedon Oct 8, 2015
Right now i'm running the parallel tests by using GNU Parallel
https://github.com/saikrishna321/AppiumAndroidParallelExecution
TikhomirovSergey commentedon Oct 8, 2015
@saikrishna321
It will be cool if you open one more issue with the detailed description. If you have any problem with it please open a new one. Today or tomorrow I'm going to propose the fix of this issue.
saikrishna321 commentedon Oct 8, 2015
@TikhomirovSergey awesome .. i will do that.. closing this ticket
Merge pull request #255 from TikhomirovSergey/#252-fix
Paul-Oginni commentedon Dec 8, 2015
It worked for me when I added the PATH variable the way TikhomirovSergey demonstrated in his screenshots.
anuja1111 commentedon Jan 31, 2016
Hi,
I have posted detailed explanation on starting and stopping Appium server with java code which works in windows as well as in Linux.
http://qaautomated.blogspot.in/2016/01/how-to-start-appium-server-using-java.html
Regards,
Anuja
jeangb commentedon Feb 14, 2017
@anuja1111 Thank you I've tried your java class and it works with success.
However, I still have the Eclipse bug meaning if I don't set PATH into Eclipse environment, my test won't be able to run on my device.
By the way, do you think it's possible to display the appium server logs elsewhere than the console in Eclipse ? For example in an other view ?
Best regards
FlexShamil commentedon Jan 16, 2018
Hello guys, I am testing chrome with my app, so as I enter email and password I get keyboard pulled up and I am unable to use pressKeyCode ENTER its just goes red. thats on 1.7.1 version for appium. per appium.io documentations those methods are supposed to be workable.
is there a solution to that?