【问题标题】:Running applescript or osascript in Sauce Remote grid在 Sauce Remote 网格中运行 applescript 或 osascript
【发布时间】:2016-05-22 23:51:57
【问题描述】:

没有解决的类似问题:Run applescript using java on selenium webdriver(Grid) in sauce lab

我需要在 iPhone 模拟器的硬件下拉菜单中使用 appleScript 单击启用 touchID。我有以下代码可以正常工作(在我授予 Eclipse 控制我的计算机的权限之后)但是当我在 saucelabs 上运行它时出现以下错误:

java.io.IOException: Cannot run program "osascript": error=2, No such file or directory
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)

这是我的代码:

 protected void enableTouchIDLogin(){
   try
   {
       String appleScriptCommand =   "tell application \"System Events\" to tell process \"Simulator\"\n" +
                       "click menu item \"Touch ID Enrolled\" of menu 1 of menu bar item \"Hardware\" of menu bar 1\n"+
                       "end tell";

       runAppleScript(appleScriptCommand);
   }
   catch (Exception e)
   {
       e.printStackTrace();
   }
}

 protected void runAppleScript(String appleScriptCommand) throws IOException{

  Runtime runtime = Runtime.getRuntime();

  String[] args = { "osascript", "-e", appleScriptCommand};
  try
  {
    Process process = runtime.exec(args);
  }
  catch (Exception e)
  {
    e.printStackTrace();
  }

};

【问题讨论】:

    标签: ios applescript appium saucelabs osascript


    【解决方案1】:
    Runtime runtime = Runtime.getRuntime();
    

    这一行将为您提供测试主机而不是远程计算机上的运行时,因此它不会在远程计算机上运行。你需要做的是以某种方式在远程机器上运行你的苹果脚本。 Appium 目前不支持它,WebDriver API 也不支持。

    https://support.saucelabs.com/customer/en/portal/articles/2135183-guide-to-pre-run-executables

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 2014-02-21
      • 2017-06-25
      • 1970-01-01
      相关资源
      最近更新 更多