获取陈旧元素参考异常:陈旧元素参考:元素未附加到页面文档
public void selectabc(WebDriver driver,String abc)引发InterruptedException {
clickabc();
Thread.sleep(3000);
WebElement select = driver.findElement(By.xpath("//div[@class='mat-select-content ng-trigger ng-trigger-fadeInContent']"));
java.util.List<WebElement> options = select.findElements(By.xpath("//div[@class='mat-select-content ng-trigger ng-trigger-fadeInContent']/mat-option/span"));
for (WebElement option : options) {
boolean StaleStatement=true;
if (option.getText().equals(abc)) {
try {
option.click();
System.out.println("Selected abc: " +abc);
Thread.sleep(3000);
StaleStatement=false;
} catch (StaleElementReferenceException e)
{
StaleStatement=true;
}
}
}
}
org.openqa.selenium.StaleElementReferenceException:陈旧元素引用:元素未附加到页面文档