0
有一个问题,为亚家伙。我正在尝试使用Selenium的流和自动化。java 8和硒
"org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document"
任何想法如何解决这个问题,而不是重写在简单的代码: 我//在这个名单我的forEach得到周围的5个按钮
getAllEditButtons().stream()
.limit(2).forEach(webElement -> {
webElement.click();
PageUtil.clearInputAndSendKeys(userPassword, password);
PageUtil.clearInputAndSendKeys(userReEnterPassword, password);
saveClient.click();
});
第一次迭代后,我得到了List<WebElement> getAllButtons;
)
我不明白LAMDA表达式,O/W我可能已经帮你 – kushal
您需要重新鉴定在每次迭代中列出元素,因为某些操作正在使该元素再次加载 – kushal
您可以从流中获取xpath等元素定位器详细信息,并将您的webelement构造为无效陈旧元素。 –