Jay
Jay

Reputation: 2527

How to use Selenium to verify Sorting of records

I have a list of records. How I can verify the sorting order using Selenium?

List<WebElement> tableRowCollection = webTableElement .findElements(By.xpath("/table")); 

I am getting an error in the above statement "The type List is not generic; it cannot be parameterized with arguments ". I am not sure how to read the records since findElements only returns WebElemt.

Upvotes: 0

Views: 6205

Answers (1)

reto
reto

Reputation: 10463

Fix your imports, you most likely are not importing java.util.List

The following code will add the text of a whole row to the collection elements:

List<WebElement> tableRowCollection = webTableElement.findElements(By.xpath("/table"))
List<String> elements = new LinkedList<String>();
for (WebElement e : tableRowCollection) {
    elements.add(e.getText());
}

This should get you started, but I really recommend you to read some documentation related to Java collections.

Upvotes: 1

Related Questions