Similar issues without resolution: Run applescript using java on selenium webdriver(Grid) in sauce lab
I need to click to enable touchID on the Hardware dropdown menu on iPhone simulator with appleScript. I have the following piece of code that works perfectly fine (after I grant Eclipse permission to control my computer) but when I run this on saucelabs I get the following error:
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)
Here is my code:
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();
}
};