Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Selenium WebDriver 3 Practical Guide

You're reading from   Selenium WebDriver 3 Practical Guide End-to-end automation testing for web and mobile browsers with Selenium WebDriver

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher Packt
ISBN-13 9781788999762
Length 280 pages
Edition 2nd Edition
Languages
Arrow right icon
Authors (3):
Arrow left icon
 Sharma Sharma
Author Profile Icon Sharma
Sharma
UNMESH GUNDECHA UNMESH GUNDECHA
Author Profile Icon UNMESH GUNDECHA
UNMESH GUNDECHA
 Avasarala Avasarala
Author Profile Icon Avasarala
Avasarala
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
1. Introducing WebDriver and WebElements FREE CHAPTER 2. Different Available WebDrivers 3. Using Java 8 Features with Selenium 4. Exploring the Features of WebDriver 5. Exploring Advanced Interactions of WebDriver 6. Understanding WebDriver Events 7. Exploring RemoteWebDriver 8. Setting up Selenium Grid 9. The PageObject Pattern 10. Mobile Testing on iOS and Android using Appium 11. Data-Driven Testing with TestNG 1. Assessments 2. Other Books You May Enjoy Index

Introducing Java 8 Stream API


The Stream API is a new addition to the Collections API in Java 8. The Stream API brings new ways to process collections of objects. A stream represents a sequence of elements and supports different kinds of operations (filter, sort, map, and collect) from a collection. We can chain these operations together to form a pipeline to query the data, as shown in this diagram:

 

We can obtain a Stream from a collection using the .stream() method. For example, we have a dropdown of languages supported by the sample web application displayed in the header section. Let's capture this in an Array list, as follows:

List<String> languages = new ArrayList<String>();
languages.add("English");
languages.add("German");
languages.add("French");

If we have to print the list members, we will use a for loop in the following way:

for(String language : languages) {
    System.out.println(language);
}

Using the streams API we can obtain the stream by calling the .stream() method...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images