【发布时间】:2016-06-09 13:21:35
【问题描述】:
我遇到了一个异常,我需要打开一个新窗口,但新窗口没有在 IOS 或 android 设备中打开。
它在 Chrome Ie 和 Firefox 与 Windows 中运行良好。
代码
driver.get("http://testdroid.com/tech/the-basics-of-mobile-web-testing-using-appium-selenium");
driver.findElement(By.xpath("//a[contains(text(),'Latest')]")).click();
String target="https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/";
String value="testEnrollWindow";
String parentHandle = driver.getWindowHandle(); // get the current window handle
String args1 = String.format("window.open('%s', '%s'); null;", target, value);
((JavascriptExecutor) driver).executeScript(args1);
driver.manage().window().maximize();
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
}
driver.close(); // close newly opened window when done with it
driver.switchTo().window(parentHandle); // switch b
【问题讨论】:
-
提及异常。可能您的移动驱动不支持该操作
-
那里没有任何异常,但没有发生切换。
标签: java python ruby selenium selenium-webdriver