I need to verify that a column in web table contains the exact same value for all rows.
I've done some coding but I'm looking for info about how to improve the performance:
- I've tried a for loop, using getText method for each row and comparing the value to an expected string:
List<WebElement> rows = driver.findElements(By.xpath(xxxx))
for(WebElement e : rows) {
if(e.getText() != expectedString) {
throwError
}
}
- I've also tried Java stream and lambda expressions, however at the end the Collector part is taking a lot of time to process:
List<String> fetchedValues = rows
.stream()
.filter(e -> e.getText() != expectedString)
.collect(Collectors.toList());
I would like to get info if at least one of the rows does not contain expected String.
Is there any way e.g. with Java to read all values in a given column and load it to ArrayList at once?