I want to select 4 products from the products list and after selecting a product the page will load and I have given the wait for page load but still, I am getting the stale exception for click and below is my code
List<WebElement> products = getDriver().findElements(By.xpath("//button[@class='icon icon-btn icon-add'][\"+(counter + 1) + \\\"]"));
System.out.println("The products Counts is: "+products.size());
Iterator<WebElement> iter = products.iterator();
int count=1;
while(iter.hasNext() && prodCount > count ) {
WebElement prod = iter.next();
prod.click();
elementUtils.waitForPageLoaded(getDriver());
count++;
}
Getting belwo exception at prod.click stale element reference: element is not attached to the page document