Now that we have introduced Streams API and its various functions, let's see how we can use them in our tests.
Using Stream API with Selenium WebDriver
Filtering and counting WebElements
Let's start with a simple test to determine the links displayed on the home page of the sample application. We get all the links from the home page and print their count, followed by the count of links that are visible on the page, as shown in the following code:
@Test
public void linksTest() {
List<WebElement> links = driver.findElements(By.tagName("a"));
System.out.println("Total Links : " + links.size());
long count = links.stream().filter(item -> item.isDisplayed()).count();
System.out.println...