【问题标题】:How to fire appium command in terminal using java in Mac?如何在 Mac 中使用 java 在终端中触发 appium 命令?
【发布时间】:2016-02-18 00:14:55
【问题描述】:

我想在 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();

但我无法在终端发送任何命令。

请提出任何解决方案。

提前致谢。 :)

【问题讨论】:

    标签: java selenium-webdriver terminal appium appium-ios


    【解决方案1】:
     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.
    

    【讨论】:

    • 嗨@Pankaj Katiyar,我尝试了你的建议。对我来说没有成功。但我是用机器人罐子做的。
    • 很奇怪,我从去年开始就使用这种方式..你能分享你得到的错误吗???你也在用 Mac 吗?
    猜你喜欢
    • 2014-06-22
    • 1970-01-01
    • 1970-01-01
    • 2014-11-02
    • 2017-09-13
    • 2020-10-01
    • 2017-07-30
    • 2018-08-15
    • 1970-01-01
    相关资源
    最近更新 更多