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構造爲無效陳舊元素。 –