【问题标题】:How to start the Appium server in iOS machine through Java code如何通过Java代码在iOS机器中启动Appium服务器
【发布时间】:2015-08-28 07:57:18
【问题描述】:

在 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 进程运行时执行方法或其他方式? 欢迎提出建议和cmets。

【问题讨论】:

    标签: java ios appium


    【解决方案1】:
    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();
        }
    }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-05-18
      • 2015-08-15
      • 1970-01-01
      • 2018-02-17
      • 2014-07-07
      • 2023-02-12
      • 2021-05-20
      • 2021-01-25
      • 2019-06-19
      相关资源
      最近更新 更多