On my web page, I’ve 25 Hyperlinks displayed inside an online desk, now i’ve to traverse all pagination pages, like 1-25, 25-50, 50-75 and many others…my particular hyperlink textual content might be in any pagination set, it may be on any web page.
<>
If the hyperlink textual content matches my string, then click on in any other case carry on clicking on “subsequent” button till i discover the hyperlink. Downside is i get "org.openqa.selenium.StaleElementReferenceException: stale aspect reference: stale aspect not discovered
because the Webelement is just not longer in DOM. I’ve tried few strategies however its not working.
Methodology 1:
Record hyperlinks = new ArrayList();
hyperlinks = driver.findElements(By.xpath("//desk[contains(@id,'table1')]//tr//a"));
if (hyperlinks.get(i).getText().equalsIgnoreCase(MatchString)) {
hyperlinks.get(0).click on();
break;
}
driver.findElement(By.linkText("subsequent")).click on();
}
Method2:
for (int i = 1; i < hyperlinks.dimension(); i++) {
//// hyperlinks = driver.findElements(By.xpath("//desk[contains(@id,'table1')]//tr//a"));
// hyperlinks = new ArrayList();
// hyperlinks = driver.findElements(By.tagName("a"));
// driver.navigate().refresh();
//
//
// if (hyperlinks.get(i).getText().trim().equalsIgnoreCase(MatchString.trim())) {
// hyperlinks.get(i).click on();
// System.out.println("Hyperlink is clicked");
// break;
// }
//
// else {
// driver.findElement(By.linkText("subsequent")).click on();
//
// }
// }