have a Search Screen where after I enter the search criteria and search a Load More button will display if there are more than 30 records. The problem is it clicks the Load more button but leads to stale element Exception
The scenario is I need to click till the Load More button becomes disabled.
Below is my code any inputs
WebElement loadmoreElems = DriverUtil.getFluentWaitElementByXPath(loadmoreXpath,20, driver);
do
{
WebDriverWait wait = new WebDriverWait(driver,10);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//span[contains(@class,'mat-button-wrapper') and contains(normalize-space(),'Load More')]")));
loadmoreElems.click(); - **The click Element leads to stale Element Exception**
loadmoreElems = DriverUtil.getFluentWaitElementByXPath(loadmoreXpath,20, driver);
if(!loadmoreElem.isDisplayed())
{
break;
} }
while(loadmoreElem.isDisplayed());
}
}
StackTrace: org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document (Session info: chrome=93.0.4577.82) For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html Build info: version: '3.14.0', revision: 'aacccce0', tim Is there anyways to get this working