Book Image

Learn Selenium

By : UNMESH GUNDECHA, Carl Cocchiaro
Book Image

Learn Selenium

By: UNMESH GUNDECHA, Carl Cocchiaro

Overview of this book

Selenium WebDriver 3.x is an open source API for testing both browser and mobile applications. With the help of this book, you can build a solid foundation and learn to easily perform end-to-end testing on web and mobile browsers. You'll begin by focusing on the Selenium Page Object Model for software development. You'll architect your own framework with a scalable driver class, Java utility classes, and support for third-party tools and plugins. Next, you'll design and build a Selenium Grid from scratch to enable the framework to scale and support different browsers, mobile devices, and platforms. You'll also strategize and handle a rich web UI using the advanced WebDriver API, and learn techniques to tackle real-time challenges in WebDriver. Later chapters will guide you through performing different types of testing, such as cross-browser testing, load testing, and mobile testing. Finally, you will be introduced to data-driven testing, using TestNG to create your own automation framework. By the end of this Learning Path, you'll be able to design your own automation testing framework and perform data-driven testing with Selenium WebDriver. This Learning Path includes content from the following Packt books: • Selenium WebDriver 3 Practical Guide - Second Edition by Unmesh Gundecha • Selenium Framework Design in Data-Driven Testing by Carl Cocchiaro
Table of Contents (25 chapters)
Title Page

What this book covers

Chapter 1, Introducing WebDriver and WebElements, will start off with an overview of Selenium and it's features. Then, we quickly jump into WebDriver by describing how it perceives a web page. We will also look at what a WebDriver's WebElement is. Then, we
talk about locating WebElements on a web page and performing some basic actions on them.

Chapter 2, Using Java 8 Features with Selenium, will talk about prominent Java 8 features such as Streams API and Lambda expressions for processing the list of WebElements. The Stream API and Lambda expression help in applying functional
programming style to create readable and fluent tests.

Chapter 3, Exploring the Features of WebDriver, will talk about some advanced features of WebDriver, such as taking screenshots of web pages, executing JavaScript, handling cookies, and handling Windows and Frames.

Chapter 4, Exploring Advanced Interactions of WebDriver, will dive deeply into more advanced actions that WebDriver can perform on the WebElements of a web page, such as the dragging and dropping of elements from one frame of a page to another and right/context-clicking on WebElements. We're sure you will find this chapter interesting to read.

Chapter 5, Understanding WebDriver Events, will deal with the event-handling aspect of WebDriver. To state a few, events can be a value change on a WebElement, a browser backnavigation invocation, script execution completion, and so on. We will use these events to run accessibility and performance checks.

Chapter 6, Exploring RemoteWebDriver, will talk about using RemoteWebDriver and Selenium Standalone Server for executing tests on remote machines from your machine.You can use the RemoteWebDriver class to communicate with the Selenium Standalone Server on a remote machine to run commands on the desired browser installed on the remote machine. One of its popular use cases is browser compatibility testing.

Chapter 7Setting up Selenium Grid, will talk about one important and interesting feature of Selenium named Selenium Grid. Using this, you can execute automated tests on a distributed computer network using Selenium Grid. We will configure a Hub and Nodes
for cross-browser testing. This also enables running tests in parallel and in a distributed architecture.

Chapter 8Data-Driven Testing with TestNG, will talk about using the data-driven testing technique with TestNG. Using the data-driven testing approach, we can reuse a test with multiple sets of test data to gain additional coverage.

Chapter 9Building a Scalable Selenium Test Driver Class for Web and Mobile Applications, shows users how to get started with designing and building the Selenium Framework driver class. This class is the engine that drives the browser and mobile applications. With Selenium WebDriver technology, users can test all the popular browsers and mobile devices using the same driver class and programming language. The Selenium WebDriver technology is platform independent and has various language bindings to support cross-browser and device testing in a single code base.

Chapter 10Selenium Framework Utility Classes, describes how to design Java utility classes to support the framework components that are non-specific to any of the applications under test. Users will learn how to build classes to perform file I/O operations, data extraction, logging, synchronization, result processing, reporting, global variables, and many more.

Chapter 11Best Practices for Building Selenium Page Object Classes, introduces users to designing and building application-specific classes following the Selenium Page Object Model. Users will be guided through designing abstract base classes, deriving sub-classes, and structuring classes to use common inheritance methods to ensure that page elements and methods are stored in central locations. In following these design principles, users will create an abstract separation layer between the page object and test classes in the framework.

Chapter 12Defining WebDriver and AppiumDriver Page Object Elements, presents users with design techniques to ensure that elements are defined using best practices for locators, minimum number of elements defined in page object classes, how to build locators on the fly, and when to use static verses dynamic locators to test page object elements.

Chapter 13Building a JSON Data Provider, explains how to design and build a TestNG DataProvider class using the JSON protocol to store data. The concept of data-driven test frameworks is introduced, and how to use a DataProvider to extract data on the fly to
ensure that standards for data encapsulation and DRY approaches are being followed is covered.

Chapter 14Developing Data-Driven Test Classes, explores how to design data-driven test classes using the TestNG technologies. This includes TestNG features such as annotations, parameters, attributes, use of DataProviders in test classes, data extraction, exception handling, and setup/teardown techniques.

Chapter 15Encapsulating Data in Data-Driven Testing, describes the use of encapsulation in data-driven testing. This will include JSON data manipulation, use of property files, processing JVM arguments, casting JSON data to Java objects, supporting multiple drivers, and parallel testing.

Chapter 16Designing a Selenium Grid, presents the Selenium Grid Architecture, including designing a virtual grid in the Cloud, how to build the grid hub, browser nodes, and Appium mobile nodes, using the grid console, how to cast tests to the RemoteWebDriver,
and supporting third-party grids.

Chapter 17Third-Party Tools and Plugins, details methodologies in using third-party tools and plugins in the Selenium Framework design. This will include the IntelliJ IDEA Selenium plugin, TestNG for results processing, the HTML Publisher Plugin, BrowserMob, ExtentReports, and Sauce Labs.

Chapter 18Working Selenium WebDriver Framework Samples, provides users with a real working sample framework including Selenium driver and utility classes, page object base and subclasses, DataProvider class, data-driven test class, JSON data file, TestNG test IListener class, and ExtentReports IReporter classes. Users will be able to install the files in their own project, use the supplied Maven pom.xml file to pull down the required JAR files, and run the sample data-driven tests against a real practice website across multiple browser types.