It’s quite common to have a list of WebElements where we want to iterate over. We can use the Java 8 Stream API feature to easily iterate over collections.
final List<String> productNames = driver .findElements(By.cssSelector("ul.product_list a.product-name")).stream() .map(WebElement::getText).collect(Collectors.toList());