how to validate webtables in web applications and capture data from rows and columns

I have tried to get data from web table but not succeeded. Please let me know the flow how to get a value from a webtable from specific row and column

Below is an example keyword to retrieve value from a cell using given row and column index:
/**
* Get text of a cell which is identified by row index and column index
* @param rowIndex Index of row, start at 1
* @param columnIndex Index of column, start at 1
* @return Value of specific cell
*/
@Keyword
def getCellText(TestObject table, int rowIndex, int columnIndex) {
WebElement eTable = WebUiBuiltInKeywords.findWebElement(table);
WebElement row = eTable.findElements(By.tagName("tr")).get(rowIndex - 1);
List<WebElement> cells = row.findElements(By.tagName("td"));
WebElement element = cells.get(columnIndex - 1)
return element.getText()
}
You need to pass in your table object and index of row/column in that table as well.

Vinh Nguyen said:

Below is an example keyword to retrieve value from a cell using given row and column index:
/**
* Get text of a cell which is identified by row index and column index
* @param rowIndex Index of row, start at 1
* @param columnIndex Index of column, start at 1
* @return Value of specific cell
*/
@Keyword
def getCellText(TestObject table, int rowIndex, int columnIndex) {
WebElement eTable = WebUiBuiltInKeywords.findWebElement(table);
WebElement row = eTable.findElements(By.tagName("tr")).get(rowIndex - 1);
List&lt;WebElement&gt; cells = row.findElements(By.tagName("td"));
WebElement element = cells.get(columnIndex - 1)
return element.getText()
}
You need to pass in your table object and index of row/column in that table as well.

Hi Vinh

When i try this approach - i get few exceptions. Is there a problem with syntax?

Thank you
Anndrew

table-question-2.jpg