我试图在我使用Java编写的代码中启动appium服务器。 我尝试下面的命令,它不工作:有没有办法让我的代码在代码中开始?
appium = Runtime.getRuntime().exec("/usr/local/bin/appium");
我试图在我使用Java编写的代码中启动appium服务器。 我尝试下面的命令,它不工作:有没有办法让我的代码在代码中开始?
appium = Runtime.getRuntime().exec("/usr/local/bin/appium");
为了启动Appium在OS X,你应该包括“开放”,并在末尾添加一个“的.app”。
例如:
appium = Runtime.getRuntime().exec("open /Applications/Appium.app");
我有同样的问题,但我使用红宝石。 问题不是服务器没有启动,服务器正在运行,但是当脚本执行时,如果服务器没有运行,就会失败。 对我而言有效的是将Appium作为一个独立的线程启动。 红宝石是这样的:
Thread.new{run_command('avm use 1.3.4 --no-reset &',1,5,false)}
我想应该有卜类似的东西,可以用Java来完成。
下面的步骤我
工作的罚款遵循这里安装的节点上,故宫的步骤。 (http://blog.teamtreehouse.com/install-node-js-npm-windows)
命令提示符:npm install -g [email protected]
#for最新
确保包括在那里你已经在你的系统环境变量安装Appium路径(我的是C:UsersXXXAppDataRoamingnpmnode_modulesappiu
)
添加以下在BeforeTest代码启动appium服务器编程
CommandLine command = new CommandLine("cmd");
command.addArgument("/c");
command.addArgument("appium");
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command, resultHandler);
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);
}
}
请详细说明“它不起作用”。什么是错误? –
没有错误,至少我看不到一个。只是该appium服务器不启动。这就像命令被传递,但它没有被执行。 – user3564094