簡體   English   中英

如何通過Java代碼在iOS機器中啟動Appium服務器

[英]How to start the Appium server in iOS machine through Java code

在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機器中完成相同的過程。 是否可以通過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();
    }
}
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM