Book Image

Selenium Testing Tools Cookbook Second Edition

By : UNMESH GUNDECHA
5 (1)
Book Image

Selenium Testing Tools Cookbook Second Edition

5 (1)
By: UNMESH GUNDECHA

Overview of this book

This book is an incremental guide that will help you learn and use the advanced features of the Selenium toolset including the WebDriver API in various situations to build a reliable test automation. You start off by setting up the test development environment and gain tips on the advanced locater strategy and the effective use of the Selenium WebDriver API. After that, the use of design patterns such as data - driven tests and PageFactory are demonstrated. You will then be familiarised with extending Selenium WebDriver API by implementing custom tasks and setting up your own distributed environment to run tests in parallel for cross-browser testing. Finally, we give you some tips on integrating Selenium WebDriver with other popular tools and testing mobile applications. By the end of this book, you will have learned enough to solve complex testing issues on your own.
Table of Contents (16 chapters)
15
Index

Using Advanced User Interactions API for mouse and keyboard events


The Selenium WebDriver's Advanced User Interactions API allows us to perform operations from keyboard events and simple mouse events to complex events such as dragging-and-dropping, holding a key and then performing mouse operations using the Actions class, and building a complex chain of events exactly like a user doing these manually.

The Actions class implements the builder pattern to create a composite action containing a group of other actions.

In this recipe, we will use the Actions class to build a chain of events to select rows in a table.

How to do it...

Let's create a test to select the multiple rows from different positions in a table using the Ctrl key (Command key on a Mac). We can select multiple rows by selecting the first row, then holding the Ctrl key (Command key on a Mac), and then selecting another row and releasing the Ctrl key (Command key on a Mac). This will select the desired rows from the table, as shown...