基本上我希望能够在单击当前按钮时出现弹出窗口时为true。我该怎么做呢?这是我的代码:
for (String handle : driver.getWindowHandles()) {
driver.switchTo().window(handle);
}
driver.close();
for (String handle : driver.getWindowHandles()) {
driver.switchTo().window(handle);
}
我正在切换到该窗口,然后关闭它并返回到原始窗口。但是如果窗口弹出,我希望能够断言。
答案 0 :(得分:1)
这是我通常做的事情:
int windowCount = driver.getWindowHandles().size();
printPDF.click();
assertEquals(windowCount + 1, driver.getWindowHandles().size());
// or the Hamcrest way, if you're familiar with it
assertThat(driver.getWindowHandles(), hasSize(windowCount + 1));
// or the FEST way, if you're familiar with it
assertThat(driver.getWindowHandles()).hasSize(windowCount + 1);