在sauce实验室的selenium webdriver(网格)上使用java运行applescript
当我们使用selenium远程web驱动程序(使用selenium网格)在MAC safari浏览器上启动https URL时,我面临认证安全问题[显示带continue的弹出窗口] 要单击“继续”按钮,我编写了apple脚本,并手动运行其工作状态良好。现在的问题是无法用java运行apple脚本 我尝试了以下方法: getting java.io.IOException:无法运行程序“osascript”:CreateProcess error=2,系统找不到指定的文件,运行以下代码时显示错误在sauce实验室的selenium webdriver(网格)上使用java运行applescript,java,macos,safari,applescript,selenium-grid,Java,Macos,Safari,Applescript,Selenium Grid,当我们使用selenium远程web驱动程序(使用selenium网格)在MAC safari浏览器上启动https URL时,我面临认证安全问题[显示带continue的弹出窗口] 要单击“继续”按钮,我编写了apple脚本,并手动运行其工作状态良好。现在的问题是无法用java运行apple脚本 我尝试了以下方法: getting java.io.IOException:无法运行程序“osascript”:CreateProcess error=2,系统找不到指定的文件,运行以下代码时显示错误
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);
}
使用ScriptEngineManager尝试在“engine.eval(applescriptCommand);”处抛出NullPointerException
请在这个问题上提供帮助。可能的副本在saucelab的OS X Mountain Lion上运行applescript还有其他替代方法吗?我仍然有这个问题…关于如何在saucelab中运行applescript有没有解决方案?可能的副本在saucelab的OS X Mountain Lion上运行applescript有其他替代方法吗?我仍然有这个问题问题…关于如何在saucelab竞选有任何决议吗?
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();
}