如何通过Java代码在iOS机器上启动Appium服务器



在Windows中,我使用Java中的命令行方法从Windows 7机器打开appium服务器,效果很好。但这在iOS系统中是做不到的。

代码:

public static void startAppiumServer() throws IOException, InterruptedException {   
        CommandLine command = new CommandLine("cmd");
        command.addArgument("/c");      
        command.addArgument("D:\SOFTWARES\AppiumForWindows-1.2.4.1\Appium\node.exe");  
        command.addArgument("D:\SOFTWARES\AppiumForWindows-1.2.4.1\Appium\node_modules\appium\bin\appium.js");  
        command.addArgument("--address", false);  
        command.addArgument("127.0.0.1");  
        command.addArgument("--port", false);  
        command.addArgument("4725");
        command.addArgument("--full-reset", false);  
        DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();  
        DefaultExecutor executor = new DefaultExecutor();  
        executor.setExitValue(1);
        executor.execute(command, resultHandler);
}

如何在iOS Machine中完成相同的过程。它是否可以由Java进程运行时执行方法或其他什么?欢迎提出建议和意见

public class AppiumServer {
public void startServer() {
    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("--full-reset", false);
    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();
    }
}
public void stopServer() {
    String[] command = { "/usr/bin/killall", "-KILL", "node" };
    try {
        Runtime.getRuntime().exec(command);
        System.out.println("Appium server stopped.");
    } catch (IOException e) {
        e.printStackTrace();
    }
}
}

相关内容

  • 没有找到相关文章

最新更新