我使用 WebDriver 编写了一些脚本,这些脚本能够完美地与 firefox 和 Chrome 一起运行。但是用 IE 运行这些脚本会导致失败。我在窗口处理机制期间遇到问题。以下是它的代码。
public void switchingWindow() {
HashSet<String> handles =(HashSet<String>) driver.getWindowHandles();;
Iterator<String> whandles = handles.iterator();
int h = 0;
while(handles.size()<2) {
handles = (HashSet<String>) driver.getWindowHandles();
whandles = handles.iterator();
System.out.println("No Of Windows : "+handles.size());
h++;
sleep(500);
if (h >= 60)
Assert.fail("Tracker PopUp not loaded successfully");
}
parentWindow = whandles.next();
popUpWindow = whandles.next();
driver.switchTo().window(popUpWindow);
System.out.println("PopUp Window is handled");
}