October 2018
Intermediate to advanced
192 pages
5h 12m
English
In the preceding example, we have used Function keyword in the form of new Function<WebDriver, WebElement>().
When we use Function, we can return any value. In this case, we return a web element. All instances of Function should have a single method called apply, which in the preceding case takes a WebDriver object as a parameter and returns the WebElement that is obtained from the findElement method. The advantage of using instances of Function is that one can pass an object of any type as the input and return an object of any type as the output.
It is not just web elements that can be returned. We can even return a Boolean condition. Boolean conditions of the kind shown in the following code are allowed:
return driver.findElements(By.id("xyz")).size() ...Read now
Unlock full access