Chapter 2

  1. Which version of Java Streams API is introduced?

Java 8.

  1. Explain the filter function of Streams API.

Java Stream API provides a filter() method to filter stream elements on the basis of the given predicate. Suppose we want to get all the link elements that are visible on the page, we can use the filter() method to return the list in the following way:

List<WebElement> visibleLinks = links.stream()
.filter(item -> item.isDisplayed())
.collect(Collectors.toList());
  1. Which method of Streams API will return the number of matching elements from the filter() function?

count().

  1. We can use the map() function to filter a list of WebElements by attribute values: True or false?

False.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.178.240