Book Image

Mastering Selenium WebDriver 3.0 - Second Edition

Book Image

Mastering Selenium WebDriver 3.0 - Second Edition

Overview of this book

The second edition of Mastering Selenium 3.0 WebDriver starts by showing you how to build your own Selenium framework with Maven. You'll then look at how you can solve the difficult problems that you will undoubtedly come across as you start using Selenium in an enterprise environment and learn how to produce the right feedback when failing. Next, you’ll explore common exceptions that you will come across as you use Selenium, the root causes of these exceptions, and how to fix them. Along the way, you’ll use Advanced User Interactions APIs, running any JavaScript you need through Selenium; and learn how to quickly spin up a Selenium Grid using Docker containers. In the concluding chapters, you‘ll work through a series of scenarios that demonstrate how to extend Selenium to work with external libraries and applications so that you can be sure you are using the right tool for the job.
Table of Contents (15 chapters)

What this book covers

Chapter 1, Creating a Fast Feedback Loop, explains how to build a basic test framework that enables you to get started quickly. You will then focus on setting up a project using Maven to download your dependencies. Then you will learn about the advantages of running tests in parallel with multiple instances of the same browser in TestNG. Next, you will learn how to make your test code portable by automatically downloading the driver binaries using a Maven plugin and run your tests without interruption by running them in headless mode.

Chapter 2, Producing the Right Feedback When Failing, explores how to cope when tests start failing. This chapter gives you a good understanding of why reliability matters and how to configure your tests to run in a Maven profile. You will get an understanding of continuous integration, continuous delivery, and continuous deployment, and set up a test build in a continuous integration server. You also learn how to connect to Selenium-Grid, how to take screenshots of test failures, and investigate the causes of test failures by reading the stack trace.  

Chapter 3, Exceptions Are Actually Oracles, provides a great deal of insight into what has gone wrong with your automated checks. You will explore the various exceptions generated by Selenium and understand what they mean. Further, you will gain a good understanding of how WebElement is a reference to an element in the DOM, understand the basic architecture of Selenium, and learn how it sends commands to the browser. 

Chapter 4, The Waiting Game, explains the most common causes of test failures in automation and also various wait solutions in Selenium. You will explore how waits work in Selenium and how you should use them to ensure that you have stable and reliable tests.

Chapter 5, Working with Effective Page Objects, discusses page objects and explains how to use them effectively without letting them get out of control. It also teaches you how to use your page objects to reduce duplication, which in turn will help you make your code concise and your automated checks more readable. Then we will finish off the chapter by understanding how to build fluent page objects.  

Chapter 6, Utilizing the Advanced User Interactions API, explains how to use the Advanced User Interactions API. You will learn how you can automate challenging scenarios such as hover menus and drag-and-drop controls. You will also explore some of the problems that you may come across when using the Advanced User Interactions API. 

Chapter 7, JavaScript Execution with Selenium, helps you understand how to use the JavascriptExecutor class. This chapter explores how you can use it to work around complex automation problems. You also learn how to execute asynchronous scripts that use a callback to notify Selenium that they have completed the execution.

Chapter 8, Keeping It Real, shows you the limitations of Selenium. You then explore various scenarios that demonstrate how to extend Selenium to work with external libraries and applications so that you will be able to use the right tool for the job.

Chapter 9, Hooking Docker into Selenium, looks at how you can use Docker with Selenium. You will understand how easy it is to start spinning up your own grid in Docker. You will also look at how you can integrate Docker into your build process.

Chapter 10, Selenium - the Future, has a look at machine learning and artificial intelligence.  You will then learn how to leverage some of that technology with Applitools EYES.

Appendix A, Contributing to Selenium, explores ways in which you can help the Selenium project.

Appendix B, Working with JUnit, explores the changes required to switch from TestNG to JUnit.

Appendix CIntroduction to Appium, explains how to create a basic Appium test framework.