As I understood from the image you shared, you are starting a new JVM inside the original one. That's why when you call the destroy function, the Java process and all of its child processes are destroyed. In my case, I was starting the Appium server from the original JVM which means that all of its spawned processes won't be destroyed until the original Java JVM terminates.
P.S: I am running more than one server instance simultaneously and I can't wait to clear up memory at the end when the JVM terminates.
Hi Everyone,
When I tried to launch the server, I am geeting this below error:
" /Applications/Appium.app/Contents/Resources/node/bin/node: cannot execute binary file "
My code is this, Can anyone please help on this ?
CommandLine command = new CommandLine("/bin/sh");
command.addArgument("/Applications/Appium.app/Contents/Resources/node/bin/node");
command.addArgument("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js");
command.addArgument("--address");
command.addArgument("127.0.0.1");
command.addArgument("--port");
command.addArgument("4723");
command.addArgument("--no-reset");
command.addArgument("--log");
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
Thanks in advance.
@Hassan_Radi : Still getting the same error.
I am using Appium version : 1.3.1 (Ophiuchus)
below is my entire code-
public static void main(String[] args) throws ExecuteException, IOException {
CommandLine command = new CommandLine("/bin/sh");
command.addArgument("/Applications/Appium.app/Contents/Resources/node/bin/node");
command.addArgument("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js");
command.addArgument("--address");
command.addArgument("127.0.0.1");
command.addArgument("--port");
command.addArgument("4723");
command.addArgument("--no-reset");
command.addArgument("--log");
command.addArgument("argument", false);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command, resultHandler);
}
I saw this line in your post,
"command.addArgument("/c");"
what does it do exactly ?
@Hassan_Radi: LOL !!
But still getting the same error, do you think its because of any device incompatibility ?
Because all I get in searching internet about this is 32-bit vs 64-bit issues only.
OS X : Version 10.8.5
Appium version : 1.3.1 (Ophiuchus)
I am running below code pn my mac no error but appium is not started as well.
Where as if i involve from terminal this command : /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js --address 127.0.0.1 --port 4723 --no-reset --local-timezone
code::
CommandLine command = new CommandLine("/bin/sh -c");
command.addArgument("/Applications/Appium.app/Contents/Resources/node/bin/node",false);
command.addArgument("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js",false);
command.addArgument("--address",false);
command.addArgument("127.0.0.1");
command.addArgument("--port",false);
command.addArgument("4723");
command.addArgument("--no-reset",false);
command.addArgument("--log");
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
try {
executor.execute(command, resultHandler);
} catch (ExecuteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I guess I missed "-c" while invoking CommandLine. Its not showing the error, but like @Sachin_Chauhan on running the code nothing is happening.
I left the hope with command line. Now I am using process builder and its working ok.
List list = new ArrayList();
list.add("/Applications/Appium.app/Contents/Resources/node/bin/node");
list.add("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js");
list.add("--address");
list.add("127.0.0.1");
list.add("--port");
list.add("4723");
list.add("--no-reset");
// create the process builder
ProcessBuilder pb = new ProcessBuilder(list);
try {
pb.start();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
I just tried with CommandLine and it worked after I changed:
CommandLine command = new CommandLine("/bin/sh -c");
command.addArgument("/Applications/Appium.app/Contents/Resources/node/bin/node",false);
to be:
CommandLine command = new CommandLine("/Applications/Appium.app/Contents/Resources/node/bin/node");
I am not sure what has changed since the last time, but it's working now without invoking the shell app.
Give it a try and let me know how it works.
@BeforeMethod
public void setUp() throws Exception {
Runtime.getRuntime().exec("/bin/bash export ANDROID_HOME=$HOME/Downloads/adt-bundle-mac-x86_64/sdk/");
CommandLine command = new CommandLine("/Applications/Appium.app/Contents/Resources/node/bin/node");
command.addArgument("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js", false);
command.addArgument("--address", false);
command.addArgument("127.0.0.1");
command.addArgument("--port", false);
command.addArgument("4723");
command.addArgument("--no-reset", false);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command, resultHandler);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "1.0");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "7.1");
capabilities.setCapability("deviceName", "iPhone 6 Plus");
capabilities.setCapability("app", "/Users/Prithivi/Documents/Sample.app");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.findElement(By.name("Continue")).click();
This works for me very well...
Note: I used java-client-1.3.0.jar, in latest version AppiumDriver was changed into interface.
thanks @Prithivi and @Hassan_Radi mine also worked. But now I am not able to create session. Even I used your
Runtime.getRuntime().exec("/bin/bash export ANDROID_HOME=$HOME/Downloads/adt-bundle-mac-x86_64/sdk/");
to set the path then also, its showing me error as 31merror[39m: Failed to start an Appium session, err was: Error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
[36minfo[39m: [debug] Error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-adb/lib/adb.js:113:12)
at ChildProcess.exithandler (child_process.js:652:7)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Socket. (child_process.js:969:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
[36minfo[39m: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.)","origValue":"Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path."},"sessionId":null}
[36minfo[39m: [37m<-- POST /wd/hub/session [39m[31m500[39m[90m 7040.310 ms - 342[39m [90m[39m
Exception while getting driver instance