有没有办法在代码中启动appium?

时间:2014-04-23 15:15:11

标签: appium

我正在尝试在使用Java编写的代码中启动appium服务器。 我尝试了以下命令但它不起作用:

appium = Runtime.getRuntime().exec("/usr/local/bin/appium");

3 个答案:

答案 0 :(得分:1)

为了在OS X上启动Appium,您应该包含'open'并在末尾添加'.app'。

例如:

appium = Runtime.getRuntime().exec("open /Applications/Appium.app");

答案 1 :(得分:0)

我有同样的问题,但我正在使用Ruby。 问题不在于服务器没有启动,服务器正在运行,但是当脚本被执行时,如果服务器没有运行就失败了。 对我有用的是将Appium作为一个单独的线程启动。 用红宝石就是这样的:

Thread.new{run_command('avm use 1.3.4 --no-reset &',1,5,false)}    

我想应该有类似的东西可以在Java中完成。

答案 2 :(得分:0)

public class StartandEndServer {
    public static void startServer() throws ExecuteException, IOException, InterruptedException{
        CommandLine command = new CommandLine("cmd");  
        command.addArgument("/c"); 
        command.addArgument("C:/Progra~2/nodejs/node.exe");  
        command.addArgument("C:/Progra~2/Appium/node_modules/appium/bin/appium.js");  
        command.addArgument("--address", false);  
        command.addArgument("127.0.0.1");  
        command.addArgument("--port", false);  
        command.addArgument("4723");  
        //command.addArgument("--no-reset");  
        command.addArgument("--full-reset", false);

        DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();  
        DefaultExecutor executor = new DefaultExecutor();  
        executor.setExitValue(1);  
        executor.execute(command, resultHandler);  

        Thread.sleep(5000);
    }
}
相关问题