我面临一个异常,我需要打开一个新窗口,但新窗口不打开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
提及异常。可能您的移动驱动程序不支持该操作 – san1deep2set3hi
在那里没有发生任何异常,但切换没有发生。 –