I use this code to validate table with single row:
List<WebElement> tableRows = driver.findElements(By.xpath(".//div[@class='ag-center-cols-container']/div/div"));
for (WebElement e : tableRows) {
if (e.getAttribute("col-id").equalsIgnoreCase("projectLookupCodes")){
System.out.println("AssertEquals value " + e.getText());
assertEquals("", e.getText());
}
if (e.getAttribute("col-id").equalsIgnoreCase("loadContainerSequence")){
System.out.println("AssertEquals value " + e.getText());
assertEquals("67", e.getText());
}
if (e.getAttribute("col-id").equalsIgnoreCase("packagedItemCount")){
System.out.println("AssertEquals value " + e.getText());
assertEquals("23", e.getText());
}
if (e.getAttribute("col-id").equalsIgnoreCase("locationName")){
System.out.println("AssertEquals value " + e.getText());
assertEquals("Location", e.getText());
}
if (e.getAttribute("col-id").equalsIgnoreCase("licensePlateLookupCode")){
System.out.println("AssertEquals value " + e.getText());
assertEquals("LP-12160", e.getText());
}
if (e.getAttribute("col-id").equalsIgnoreCase("shipmentLookupCode")){
System.out.println("AssertEquals value " + e.getText());
assertEquals("520031", e.getText());
}
}
HTML code:
How I can verify each table row? Currently it's searching for first row and so on. How this code can be extended to search for several table rows values.