【发布时间】:2020-06-19 10:56:13
【问题描述】:
我正在网页上进行分页。其中 20 个帐户已加载到页面上,再次单击按钮后,另一个 20 个帐户已加载。第三次点击按钮从网页上消失后,所有帐户都已加载。但我得到以下错误:
“org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attach to the page document”
下面是代码:
public static WebDriver driver;
public static List<WebElement> tarif;
public static Actions action;
public static boolean flag;
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
tarif = driver.findElements(By.xpath("//button[contains(text(),'tarife')]"));
flag = true;
while(flag) {
System.out.println(flag);
System.out.println(tarif.size());
if (tarif.size() > 0) {
//try {
Actions action = new Actions(driver);
action.moveToElement(tarif.get(0)).build().perform();
Thread.sleep(5000);
tarif.get(0).click();
} else {
flag = false;
}
}
Thread.sleep(5000);
driver.quit();
你们能帮我解决以上问题吗?
【问题讨论】:
标签: java selenium-webdriver cucumber cucumber-junit