sam
sam

Reputation: 57

How to get all the values against a particular tag in webpage

Is there any way to get all the values displaying against "BRAND" .

I want to store all the value that will display for the BRAND and sore those value in the collection so that I can compare with one more collection and find which value will get match in between those.

below is the screenshot . Please give some input .

enter image description here

Upvotes: 0

Views: 98

Answers (1)

pburgr
pburgr

Reputation: 1778

Probably the simplest way:

List<String> brands = new ArrayList<String>();
List<WebElement> fields = driver.findElements(By.className("asset-page__field-value"));
for (WebElement field: fields) {
    brands.add(field.getText());
}

Upvotes: 1

Related Questions