1

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.

  • possible duplicate of [Java ScriptEngineManager no longer works with Mountain Lion's AppleScript](http://stackoverflow.com/questions/11978407/java-scriptenginemanager-no-longer-works-with-mountain-lions-applescript) – RealSkeptic Sep 30 '15 at 11:26
  • There is an any other alternative way to run applescript on OS X Mountain Lion in saucelab? – Manibharathi Sundaram Sep 30 '15 at 16:27
  • I still have this question...any resolution on how to run in saucelab? – es3735746 Feb 11 '16 at 21:44

0 Answers0