I am facing certification security issue[showing popup with continue] when we launch https URL on MAC safari browser using selenium remote web-driver(using selenium grid)
To click "continue" button, I wrote the apple script and ran manually its working fine. Now the problem is not able to run the apple script in java.
I tried with below ways::
getting java.io.IOException: Cannot run program "osascript": CreateProcess error=2, The system cannot find the file specified, error getting displayed while we running the below code
String applescriptCommand = "tell application \"System Events\"\n" + "if (exists of application process \"Safari\") is true then\n" + "tell process \"Safari\"\n" + "if (exists of sheet 1 of window 1) is true then\n" + "delay 1" + "click button \"Continue\" of group 2 of sheet 1 of window 1\n" + "delay 2\n" + "end if\n" + "end tell\n" + "end if\n" + "end tell";
String[] args = {"osascript", "-e", applescriptCommand};
Process process = Runtime.getRuntime().exec(args);
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getErrorStream()));
String lsString;
while ((lsString = bufferedReader.readLine()) != null) {
System.out.println(lsString);
}
Tried with ScriptEngineManager its throwing NullPointerException at "engine.eval(applescriptCommand);"
String applescriptCommand = "tell application \"System Events\"\n" + "if (exists of application process \"Safari\") is true then\n" + "tell process \"Safari\"\n" + "if (exists of sheet 1 of window 1) is true then\n" + "delay 1" + "click button \"Continue\" of group 2 of sheet 1 of window 1\n" + "delay 2\n" + "end if\n" + "end tell\n" + "end if\n" + "end tell";
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("AppleScriptEngine");
try {
engine.eval(applescriptCommand);
} catch (ScriptException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
kindly help on this issue.