I am able to execute the code below, and it even clicks on my expected text. But the issue is that after clicking, I get a
org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
Here is my code snippet
String ExpectedPosition = findTestData(‘PositionNames’).getValue(1, 1)
WebDriver driver = DriverFactory.getWebDriver()
WebElement PositionTable = driver.findElement(By.xpath('//td[2]/table/tbody/tr/td/table'))
List<WebElement> Rows = PositionTable.findElements(By.tagName('tr'))
println('No. of rows: ' + Rows.size())
table: for (int i = 0; i < Rows.size(); i++) {
List<WebElement> Cols = Rows.get(i).findElements(By.tagName('td'))
for (int j = 0; j < Cols.size(); j++) {
if (Cols.get(j).getText().equalsIgnoreCase(ExpectedPosition)) {
Cols.get(j).findElement(By.tagName('a')).click()
WebUI.delay(5)
table: break
}
}
}