osx - Run applescript using java on selenium webdriver(Grid) in sauce lab -
i facing certification security issue[showing popup continue] when launch https url on mac safari browser using selenium remote web-driver(using selenium grid)
to click "continue" button, wrote apple script , ran manually working fine. problem not able run apple script in java.
i tried below ways::
getting java.io.ioexception: cannot run program "osascript": createprocess error=2, system cannot find file specified, error getting displayed while running below code
string applescriptcommand = "tell application \"system events\"\n" + "if (exists of application process \"safari\") true then\n" + "tell process \"safari\"\n" + "if (exists of sheet 1 of window 1) 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 scriptenginemanager throwing nullpointerexception @ "engine.eval(applescriptcommand);"
string applescriptcommand = "tell application \"system events\"\n" + "if (exists of application process \"safari\") true then\n" + "tell process \"safari\"\n" + "if (exists of sheet 1 of window 1) 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 on issue.
Comments
Post a Comment