Starting Appium 1.6 programmatically in Mac

I was using the earlier version of Appium, and was able to start the appium server through following Java code. I have installed Appium 1.6 now. I have added the capability automationName: XCUITest. What needs to be changed here to make it work with the new Appium?:

> 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("0.0.0.0");
>         command.addArgument("--port", false);
>         command.addArgument("4723");
>         command.addArgument("--full-reset", false);
>         command.addArgument("--log-level", false);
>         command.addArgument("error");
>         DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
>         DefaultExecutor executor = new DefaultExecutor();
>         executor.setExitValue(1);

>             executor.execute(command, resultHandler);

appium.js - is when you installed DMG file but 1.6.0 is npm install THUS is it enough only “appium” to start it in command line.

@arindam

Below is how I start appium server programmatically using 1.6.3

  1. Open Terminal
  2. Enter: which node
  3. Copy that path in the NodePath below
  4. Enter: which appium
  5. Copy that path in the AppiumPath below

CommandLine command = new CommandLine("[NodePath]");
command.addArgument("[AppiumPath]",false);
command.addArgument("–address", false);
command.addArgument(“127.0.0.1”);
command.addArgument("–port", false);
command.addArgument(strAppiumPort);
command.addArgument("-bp", false);
command.addArgument(strBootstrapPort);
command.addArgument("–full-reset", true);
command.addArgument("–session-override", true);
//command.addArgument("–no-reset", true);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
try {executor.execute(command, resultHandler);
Thread.sleep(5000);System.out.println(“Appium server started.”);}
catch (IOException e)
{e.printStackTrace();}
catch (InterruptedException e)
{e.printStackTrace();}

DD

1 Like

Is there a way to get the logs so it won’t be printed as an output ?