I'm trying to set up appium test headless with java:
public void startAppiumServer() throws IOException, InterruptedException {
// Process process;
String APPIUMSERVERSTARTCMD = "cmd /c " + "\"C:/Program Files (x86)/Appium/node.exe\" " +
"\"C:/Program Files (x86)/Appium/node_modules/appium/bin/Appium.js\" " +
"--address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 4725 " +
"--selendroid-port 8082 --no-reset --local-timezone --log G:/log_appium.txt";
Runtime rt = Runtime.getRuntime();
Log.debug("Send command : " + APPIUMSERVERSTARTCMD);
final Process pr = rt.exec(APPIUMSERVERSTARTCMD);
new Thread(new Runnable() {
public void run() {
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = null;
try {
while ((line = input.readLine()) != null)
System.out.println(line);
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
pr.waitFor();
}
But the appium app did not launch. if i except "cmd /c ", appium will run successfully. But the test just run appium, don't do something else. I want to run my test case after appium launched.
@BeforeSuite
public void initAndroidTest() throws IOException, InterruptedException {
LaunchAppium launchAppium = new LaunchAppium();
launchAppium.startAppiumServer();
try {
AppiumRemote remote = new AppiumRemote(driver);
driver = remote.remoteDevice();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
homePage = CommonFlow.goToMainPage(driver);
}catch (Exception ex){
}
}
public static AndroidDriver getDriver() { return driver; }
@Test
public void runLogin(){
LoginTester login = new LoginTester();
login.runTest(driver, homePage);
}
Please help me to solve this problem. Thanks