I am trying to iterate through a table and click on a certain button found on one of the rows of this table.
I do this by doing this:
String ExpectedValue = ‘CI: 47241111’
WebDriver driver = DriverFactory.getWebDriver()
WebElement Table = driver.findElement(By.id(‘GridContainerDiv’))
List Rows = Table.findElements(By.tagName(‘tr’))
println('No. of rows: ’ + Rows.size())
table: for (int i = 0; i < Rows.size(); i++) {
List Cols = Rows.get(i).findElements(By.tagName(‘td’))
for (int j = 0; j < Cols.size(); j++) {
println(Cols.get(i).getText())
if (Cols.get(j).getText().equalsIgnoreCase(ExpectedValue)) {
WebUI.delay(3)
Cols.get(1).findElement(By.tagName(‘img’)).click()
break;
}
}
}
The problem with this is that it throws the next error:
org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
I try to solve this problem by waiting for the element to be visible but this is not working either. It throws the next error:
No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.waitForElementVisible() is applicable for argument types: (org.openqa.selenium.remote.RemoteWebElement, java.lang.Integer, com.kms.katalon.core.model.FailureHandling) values: [[[[[[[[[CChromeDriver: chrome on XP (afbc4a2b4b73efefff11b16b9b731b20)] → id: GridContainerDiv]] → tag name: tr]] → tag name: td]] → tag name: img], …]
This is the html surrounding the button in the table: