Skip to Main Content
Mastering Selenium WebDriver 3.0 - Second Edition
book

Mastering Selenium WebDriver 3.0 - Second Edition

by Mark Collin
June 2018
Beginner to intermediate content levelBeginner to intermediate
376 pages
8h 58m
English
Packt Publishing
Content preview from Mastering Selenium WebDriver 3.0 - Second Edition

Functions

We are going to create a very basic function that will find and return WebElement. Take a look at this code:

Function<WebDriver, WebElement> weFindElementFoo = new Function<WebDriver, WebElement>() {     public WebElement apply(WebDriver driver) {         return driver.findElement(By.id("foo"));     } };

The function may look confusing, but it is actually quite simple. It is simply specifying an input and an output. Let's break it down and take the object definition in isolation. Look at this code:

Function<WebDriver, WebElement> weFindElementFoo 

What we are saying is that we are going to create a function named weFindElementFoo(). We are going to supply this function with an object of type WebDriver as the input, and we will get an object of ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Selenium WebDriver 3 Practical Guide - Second Edition

Selenium WebDriver 3 Practical Guide - Second Edition

Pallavi Sharma, UNMESH GUNDECHA, Satya Avasarala

Publisher Resources

ISBN: 9781788299671Supplemental Content