public static List<String> texts(Collection<WebElement> elements) {
    return elements.stream().map(ElementsCollection::getText).collect(toList());
  }
public static List < String > texts ( Collection < WebElement > elements ) { return elements . stream ( ) . map ( ElementsCollection :: getText ) . collect ( toList ( ) ) ; }
Fail-safe method for retrieving texts of given elements.
@param elements Any collection of WebElements
@return Array of texts (or exceptions in case of any WebDriverExceptions)