-1

In a web table one column name is Bank and another column name is amount and i want to fetch the highest amount along with bank name in my output .How we will do it in selenium , this webtable is present in web application

shruti
  • 1

1 Answers1

0

Basically you need to extract the data from table and store it in list and then do sort or find max from the list.

Below is sample code to extract the table entries and store in list then you can do what every you want in java.

//To locate table.
WebElement mytable = wd.findElement(By.xpath("<path to your table>"));
//To locate rows of table. 
List < WebElement > rows_table = mytable.findElements(By.tagName("tr"));
//To calculate no of rows In table.
int rows_count = rows_table.size();
//Loop will execute till the last row of table.
for (int row = 0; row < rows_count; row++) {
    //To locate columns(cells) of that specific row.
    List < WebElement > Columns_row = rows_table.get(row).findElements(By.tagName("td"));
    //To calculate no of columns (cells). In that specific row.
    int columns_count = Columns_row.size();
    System.out.println("Number of cells In Row " + row + " are " + columns_count);
        //Loop will execute till the last cell of that specific row.
    for (int column = 0; column < columns_count; column++) {
        // To retrieve text from that specific cell.
        String celtext = Columns_row.get(column).getText();
        System.out.println("Cell Value of row number " + row + " and column number " + column + " Is " + celtext);
    }
    System.out.println("-------------------------------------------------- ");
}

Below is link which has same thing explained.

How to check webelements in webtable is sorted alphabetically using selenium webdriver?

Shahid Farooq
  • 104
  • 2
  • 10