我想在Mac中使用java以编程方式启动appium服务器。 我可以使用以下代码打开终端:
String cmd= "osascript -e \"tell app \\\"Terminal\\\" to activate\"";
List<String> command1=new ArrayList<String>();
command1.add("/bin/sh");
command1.add("-c");
command1.add(cmd);
ProcessBuilder pb=new ProcessBuilder(command1);
pb.start();
但我无法在终端发送任何命令。
请建议任何解决方案。
提前致谢。 :)
答案 0 :(得分:0)
It seems you are trying to open Terminal app, which is not required rather you can try this:
There are many ways to do start appium programatically:
1. Create a text file and write command: export PATH=$PATH:/usr/local/bin; /usr/local/bin/appium & -g /tmp/app.log --command-timeout 90 and save this file with .sh extension say test.sh and give executable permission to this file like chmod +x test.sh
2. Now you can execute this command using your java code like: Runtime.getRuntime().exec("<PATH_TO_FILE>/test.sh");
Thats all. You can check if appium is running by browsing localhost:4723,
if you are writing further tests, you need to wait until appium server is started in your code.