Reader small image

You're reading from  Selenium WebDriver 3 Practical Guide - Second Edition

Product typeBook
Published inJul 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781788999762
Edition2nd Edition
Languages
Right arrow
Authors (3):
Pallavi Sharma
Pallavi Sharma
author image
Pallavi Sharma

Pallavi Sharma is a founder of 5 Elements Learning. She has 12 years professional experience. She has worked in varied roles as a product/project manager, in presales team, marketing team, and test automation coach in the software testing domain. Being an avid learner, she also likes to keep herself up to date with the latest trends and technologies. She is a firm believer that there is no shortcut to success.
Read more about Pallavi Sharma

UNMESH GUNDECHA
UNMESH GUNDECHA
author image
UNMESH GUNDECHA

Unmesh Gundecha has over 16 years, experience in Agile software development, test automation, and DevOps methodologies. He is an Agile, open source, and DevOps evangelist with extensive experience in a diverse set of tools and technologies. He has extensive hands-on experience in building sustainable and repeatable test automation solutions for web and mobile platforms, APIs, and CLI apps with continuous integration and delivery pipelines, using best-of-breed open source and commercial tools to do so. He is the author of Selenium Testing Tools Cookbook and Learning Selenium Testing Tools with Python, both by Packt Publishing.
Read more about UNMESH GUNDECHA

Satya Avasarala
Satya Avasarala
author image
Satya Avasarala

Satya Avasarala has rich experience in Java development and automation testing. He is an engineer in computer science. He has used WebDriver for many years now and has created several good automation frameworks. He has worked at various large software enterprises such as Oracle Corp, Yahoo! Inc., VMware Inc., and the REA Group. In addition, he is also interested in Service Oriented Architectural design and Business Intelligence. He is an Oracle-certified Service Oriented Architecture Infrastructure Implementation Expert and a Business Intelligence Foundation Suite Implementation Specialist.
Read more about Satya Avasarala

View More author details
Right arrow

Preface

This book is about Selenium WebDriver, that is, a browser automation tool used by software developers and QA engineers to test their web application on different web browsers. This book can be used as a reference for your day-to-day usage of WebDriver.

Selenium is a set of tools for automating browsers. It is largely used for testing applications, but its usages are not limited only to testing. It can also be used for screen scraping and automating repetitive tasks in a browser window. Selenium supports automation on all the major browsers, including Firefox, Internet Explorer, Google Chrome, Safari, and Opera. Selenium WebDriver is now a part of W3C standards, and it is supported by major browser vendors.

Who this book is for

If you are a quality assurance/testing professional, test engineer, software developer, or web application developer looking to create automated test suites for your web applications, this is the perfect guide for you! As a prerequisite, this book expects you to have a basic understanding of Java programming although any previous knowledge of WebDriver or Selenium is not needed. By the end of this book, you will have acquired a comprehensive knowledge of WebDriver, which will help you in writing your automation tests.

What this book covers

Chapter 1, Introducing WebDriver and WebElements, will start off with an overview of Selenium and the 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, Working with Browser Drivers, will talk about various implementations of WebDriver, such as FirefoxDriver, IEDriver, and ChromeDriver. We will configure browser options to run tests in headless mode, mobile emulation, and use custom profiles. With WebDriver becoming a W3C specification, all major browser vendors now support WebDriver natively in the browser.

Chapter 3, Using Java 8 Features along 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 4, 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 5, Exploring Advanced Interaction API, 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 6, 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 back-navigation invocation, script execution completion, and so on. We will use these events to run accessibility and performance checks.

Chapter 7, 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 8, Setting 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 9, The PageObject Pattern, will talk about a well-known design pattern named the PageObject pattern. This is a proven pattern that will give you a better handle on your automation framework and scenarios for better maintainability.

Chapter 10, Mobile Testing on iOS and Android Using Appium, will take you through how WebDriver can be used to automate your test scripts for iOS and Android platform using Appium.

Chapter 11, Data-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.

To get the most out of this book

The reader is expected to have a basic idea of programming, preferably using Java because we take the reader through several features of WebDriver using code examples. The following software is required for the book:

  1. Oracle JDK8
  2. Eclipse IDE
  3. Maven 3
  4. Google Chrome
  5. Mozilla Firefox
  6. Internet Explorer or Edge (on Windows)
  7. Apple Safari
  8. Appium

Installing Java

Installing Eclipse

This book is a practical guide that expects the user to write and execute WebDriver examples. For this, it would be handy to install a Java IDE. The Eclipse IDE is a popular choice in Java user community. The Eclipse IDE can be downloaded from https://www.eclipse.org/downloads/.

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Selenium-WebDriver-3-Practical-Guide-Second-Edition. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "beforeMethod(), which is annotated with the @BeforeMethod TestNG annotation."

A block of code is set as follows:

<input id="search" type="search" name="q" value="" class="input-text required-entry" maxlength="128" placeholder="Search entire store here..." autocomplete="off">

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

WebElement searchBox = driver.findElement(By.id("q"));

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "To run the tests, right-click in the code editor and select Run As | TestNG Test, as shown in the following screenshot."

Warnings or important notes appear like this.
Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email feedback@packtpub.com and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at questions@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packtpub.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Selenium WebDriver 3 Practical Guide - Second Edition
Published in: Jul 2018Publisher: PacktISBN-13: 9781788999762
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.
undefined
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

Authors (3)

author image
Pallavi Sharma

Pallavi Sharma is a founder of 5 Elements Learning. She has 12 years professional experience. She has worked in varied roles as a product/project manager, in presales team, marketing team, and test automation coach in the software testing domain. Being an avid learner, she also likes to keep herself up to date with the latest trends and technologies. She is a firm believer that there is no shortcut to success.
Read more about Pallavi Sharma

author image
UNMESH GUNDECHA

Unmesh Gundecha has over 16 years, experience in Agile software development, test automation, and DevOps methodologies. He is an Agile, open source, and DevOps evangelist with extensive experience in a diverse set of tools and technologies. He has extensive hands-on experience in building sustainable and repeatable test automation solutions for web and mobile platforms, APIs, and CLI apps with continuous integration and delivery pipelines, using best-of-breed open source and commercial tools to do so. He is the author of Selenium Testing Tools Cookbook and Learning Selenium Testing Tools with Python, both by Packt Publishing.
Read more about UNMESH GUNDECHA

author image
Satya Avasarala

Satya Avasarala has rich experience in Java development and automation testing. He is an engineer in computer science. He has used WebDriver for many years now and has created several good automation frameworks. He has worked at various large software enterprises such as Oracle Corp, Yahoo! Inc., VMware Inc., and the REA Group. In addition, he is also interested in Service Oriented Architectural design and Business Intelligence. He is an Oracle-certified Service Oriented Architecture Infrastructure Implementation Expert and a Business Intelligence Foundation Suite Implementation Specialist.
Read more about Satya Avasarala