我正在尝试切换到另一个弹出窗口,但出现了某种错误。我无法弄清楚为什么代码不能用于切换窗口
它给出的错误是
java.lang.NullPointerException:条目中的空值:name=null
这是代码....
String parentWindowHandle = driver.getWindowHandle();
System.out.println("parentWindowHandle......"+parentWindowHandle);
//click on "register"
Actions act = new Actions(driver);
act.click(driver.findElement(By.id("ctl00_ContentPlaceHolder1_btnRegisterMe")));
act.perform();
sleep(26000);
String popUpWindowHandle=null;
Set<String> openWindowsList = driver.getWindowHandles();
for (String windowHandle : openWindowsList) {
System.out.println("windowHandle......"+windowHandle);
if (!windowHandle.equals(parentWindowHandle))
{popUpWindowHandle = windowHandle;
break;}
}
// Switching control to newly opened window
driver.switchTo().window(popUpWindowHandle);