以下代码忽略第二个复选框单击。有谁知道为什么以及如何解决?在最后一行设置断点以查看复选框仍处于选中状态...
private final static String CHECKBOXBUTTON_URL = "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_Checkbox";
private final static String RESULT_IFRAME = "iframeResult";
private final static By CHECKBOX = By.xpath("/html/body/form/input[2]");
@Test
public void checkbox()
{
System.setProperty("webdriver.edge.driver", "MicrosoftWebDriver.exe");
WebDriver driver = new EdgeDriver();
FluentWait<WebDriver> wait = new WebDriverWait(driver, 0);
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
wait.withTimeout(Duration.ofSeconds(10)).pollingEvery(Duration.ofMillis(200));
driver.get(CHECKBOXBUTTON_URL);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(RESULT_IFRAME));
driver.findElement(CHECKBOX).click();
wait.until(ExpectedConditions.elementToBeSelected(CHECKBOX));
driver.findElement(CHECKBOX).click(); // this click is ignored
driver.quit(); // break here; checkbox is still checked (but shouldn't)...
}