Launch Appium Server using Java Program

It may be a good approach to start appium server via program instead start it manually while automating a mobile application. For this, we use Process class of Java and pass path of Node.exe and Appium.js on your system

Prerequisites:

  • Appium Executable for Windows
  • JDK

Code to Start Appium Server:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class AppiumProg {
public static void main(String[] args) {
try
{
String line;
Process p = Runtime.getRuntime().exec("\"C:/Program Files (x86)/Appium/node.exe\" \"C:/Program Files (x86)/Appium/node_modules/appium/bin/Appium.js\" –no-reset –local-timezone");
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = in.readLine()) != null) {
System.out.println(line);
}
try
{
Thread.sleep(10000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
p.destroy();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}

view raw
AppiumServerStart
hosted with ❤ by GitHub

Advantages:

  • It will reduce manual effort to start appium server.
  • It will help to achieve complete automation.

1 thought on “Launch Appium Server using Java Program

Leave a Reply

%d bloggers like this: