Book Image

Learning Selenium Testing Tools - Third Edition

Book Image

Learning Selenium Testing Tools - Third Edition

Overview of this book

Table of Contents (22 chapters)
Learning Selenium Testing Tools Third Edition
About the Author
About the Reviewers


Selenium WebDriver is the most used automation tool for web-based applications. This book shows beginners, developers, and testers how to create automated test cases using Selenium. You will be able to use Selenium IDE for quick throwaway tests and you will learn to use Selenium WebDriver along with the automation framework development.

You will learn how to use Selenium WebDriver with both desktop browsers and mobile browsers as well learn good design patterns to ensure your tests will be extremely maintainable.

We have provided prerequisites as well, so that you are well versed with the topics needed to understand testing with Selenium. You will therefore not have to refer to other external sources to understand these topics.

What this book covers

Chapter 1, Getting Started with Selenium IDE, explains how to install Selenium IDE and record our first tests. We will see what is needed to work against AJAX applications.

Chapter 2, Locators, shows how we can find elements on the page to be used in our tests. We will use XPath, CSS, link text, and ID to find elements on the page so that we can interact with them.

Chapter 3, Overview of the Selenium WebDriver, discusses all the history and architectural designs for Selenium WebDriver. You will also go through the necessary items for setting up a development environment.

Chapter 4, Finding Elements, explains all the different techniques in searching elements using Selenium WebDriver. This chapter builds on the locators that we learned in Chapter 2, Locators.

Chapter 5, Design Patterns, introduces the different design patterns that can be used with Selenium WebDriver. The design patterns will show you how to make your tests more maintainable and allow more people to work on your code.

Chapter 6, Working with WebDriver, introduces all the different aspects of getting different browsers that Selenium WebDriver supports on desktop operating systems.

Chapter 7, Automation Framework Development and Building Utilities, explains the various types of automation frameworks and how to build the Hybrid automation framework with the design, architecture, and implementation. We are giving a plug and play Hybrid automation framework for Selenium WebDriver with the code bundle of this book.

Chapter 8, Mobile Devices, explains how Selenium WebDriver works on mobile devices to test mobile websites or sites built with responsive web design.

Chapter 9, Getting Started with the Selenium Grid, shows us how we can set up our Selenium Grid. We will also take a look at running tests in parallel to try bringing down the time it takes to run tests.

Chapter 10, Advanced User Interactions, explains how to build chains of actions together to help when you need to drag and drop or have key combinations working. We will also look at how we can press a mouse button and hold it down while we move the mouse.

Chapter 11, Working with HTML5, explains working with some of the HTML5 technologies that are becoming available to browsers. The Selenium WebDriver APIs are very similar to the JavaScript APIs in the browser in order to make use of them easier.

Chapter 12, Advanced Topics, explains how to capture network traffic between the browser and the web server. We finish off by capturing screenshots.

Chapter 13, Migrating from Remote Control to WebDriver, introduces how the interaction with the browser has changed and how we can convert our Selenium 1 tests to Selenium 2 to take advantage of the changes in Selenium WebDriver.

Appendix A, Automation Prerequisites for Selenium Automation, deals with the basics of Java and prerequisites related to programming, which is mandatorily required for automation testing. We are giving an automation prerequisites-related program of examples with this book.

Appendix B, Answers for Self-test Questions, has the answers to all the self-test questions in the previous chapters.

What you need for this book

  • Mozilla Firefox

  • Google Chrome

  • Internet Explorer

  • Opera

  • Eclipse or IntelliJ IDEA

  • Firebug

  • Firefinder

  • Xpath finder / XPath viewer (Firefox add-ons)

  • Selenium IDE

  • Selenium Grid

  • Ubuntu Linux

Who this book is for

If you are a software quality assurance professional, software project manager, or a software developer interested in automated testing using Selenium, this book is for you. Web-based application developers will also benefit from this book.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "If an item fails, then it will have an [error] entry."

A block of code is set as follows:

public void shouldCheckButtonOnChapter2Page(){
Assert.assertEquals(selenium.findElements("but1")).size(), 1);

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

adb -s <serialId> forward tcp:8080 tcp:8080

Any command-line input or output is written as follows:

db shell am start -a android.intent.action.MAIN -n

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click Build & Go! iWebDriver will be installed on the device."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.