我点击myApplication中的链接将我重定向到safari,现在我想关闭safari并在相同的状态下打开回myApplication?appium不支持Home按钮。
尝试过,
1.
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("UIATarget.localTarget().deactivateAppForDuration(5); 但它正在关闭和再次打开Safari应用程序。如何切换到myApplication而不是safari?
driver.closeApp();
driver.launchApp();退出驱动程序。
3.
JavascriptExecutor js = (JavascriptExecutor) driver;
Object result = js.executeScript("mobile: closeApp");
HashMap<String, String> args = new HashMap<String, String>();
args.put("bundleId", "com.myApplication.iphone");
js.executeScript("mobile: launchApp", args);出现"org.openqa.selenium.WebDriverException: Not implemented“错误。
4.
Runtime runtime = Runtime.getRuntime();
String[] args = {"osascript", "-e", "tell app \"safari\" to quit"};
runtime.exec(args);
runtime = Runtime.getRuntime();
String[] cmd = { "osascript", "-e", "tell app \"myApplication\" to launch" };
runtime.exec(cmd);不起作用。
5.
try {
Robot robot = new Robot();
// Simulate a key press
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_H);
// Simulate a key press
robot.keyRelease(KeyEvent.VK_H);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.keyRelease(KeyEvent.VK_CONTROL);
} catch (AWTException e) {
e.printStackTrace();
}不工作
发布于 2015-12-12 02:44:28
我能看到的最好的方法是设置你想要的功能,不在会话caps.setCapability("noReset", true)之间重置应用程序。
然后,在您单击Safari上的链接并执行您需要做的任何其他操作后,关闭会话driver.quit()并再次使用您的应用程序启动一个新会话。它应该从您停止的地方开始。
https://stackoverflow.com/questions/34208636
复制相似问题