【发布时间】: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