Reputation: 1237
I have a question regarding list of web elements. I have a method that verify if text exists in list of web elements. I need to modify it to support attribute title, and validate if value exists. Is their a way to change this method to support attribute title?
My method:
public Boolean isStringInWebElementsAttributeList(String expectedValue,List<WebElement> dropdownOptions) throws Exception {
Boolean isExists = dropdownOptions.stream().map(WebElement::getText).anyMatch(text -> expectedValue.equals(text));
return isExists;
}
Upvotes: 0
Views: 50
Reputation: 5818
Instead of mapping the getText
map the element's title
attribute.
public Boolean isStringInWebElementsAttributeList(String expectedValue,List<WebElement> dropdownOptions) throws Exception {
Boolean isExists = dropdownOptions.stream()
.map(el->el.getAttribute("title"))
.anyMatch(text -> expectedValue.equals(text));
return isExists;
}
Upvotes: 1