1. 切换到另一个handle
Set<String> winHandles;
winHandles = driver.getWindowHandles();
Assert.assertEquals(winHandles.size(), 2, "message.");
for (String handle : winHandles) {
if (!handle.equals(mainHandle)) {
driver.switchTo().window(handle);
break;
}
}
2. 切换到iframe
String mainHandle = driver.getWindowHandle();
driver.switchTo().frame(driver.findElement(By.cssSelector("#MIFind")));