我面临一个例外,我需要打开一个新窗口,但新窗口在IOS或android设备中无法打开。你知道吗
在Chrome Ie和带有Windows的Firefox中工作得非常好。你知道吗
代码
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
我在移动设备上运行测试时也遇到了同样的问题。经过多次尝试,我发现是窗户大小造成的。你知道吗
所以删除
driver.manage().window().maximize();
相关问题 更多 >
编程相关推荐