-
-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to run Appium server programmatically #252
Comments
Hi @saikrishna321 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. |
It is the problem of Eclipse for Mac OS. As soon as possible I'll post the way to resolve the problem |
@saikrishna321
... 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:
@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. |
@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(). |
@saikrishna321 Yep new AppiumServiceBuilder().
withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER,"Your port number"); 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. |
The issue is marked closed now however i have the solution which works perfectly for me without using any configuration in eclipse at all. public class Utils {
private static final String[] WIN_RUNTIME = { "cmd.exe", "/C" };
private static final String[] OS_LINUX_RUNTIME = { "/bin/bash", "-l", "-c" };
private Utils() {
}
private static <T> T[] concat(T[] first, T[] second) {
T[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
return result;
}
public static List<String> runProcess(boolean isWin, String... command) {
System.out.print("command to run: ");
for (String s : command) {
System.out.print(s);
}
System.out.print("\n");
String[] allCommand = null;
try {
if (isWin) {
allCommand = concat(WIN_RUNTIME, command);
} else {
allCommand = concat(OS_LINUX_RUNTIME, command);
}
ProcessBuilder pb = new ProcessBuilder(allCommand);
pb.redirectErrorStream(true);
Process p = pb.start();
p.waitFor();
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String _temp = null;
List<String> line = new ArrayList<String>();
while ((_temp = in.readLine()) != null) {
System.out.println("temp line: " + _temp);
line.add(_temp);
}
System.out.println("result after command: " + line);
return line;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
} @TikhomirovSergey it would be time saver if this could be integrated with java client. |
@pr4bh4sh |
@TikhomirovSergey to trigger the test in parallel i must pass the android device serial as well UDID. How can i pass this ? |
Right now i'm running the parallel tests by using GNU Parallel https://github.com/saikrishna321/AppiumAndroidParallelExecution |
@saikrishna321 |
@TikhomirovSergey awesome .. i will do that.. closing this ticket |
It worked for me when I added the PATH variable the way TikhomirovSergey demonstrated in his screenshots. |
Hi, I have posted detailed explanation on starting and stopping Appium server with java code which works in windows as well as in Linux. Regards, |
@anuja1111 Thank you I've tried your java class and it works with success. |
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? |
@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") + "/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)
The text was updated successfully, but these errors were encountered: