Selenium WebDriver Quick Start Guide

Book Description

Get writing tests and learn to design your own testing framework with Selenium WebDriver API

Key Features

  • Learn Selenium from the ground up
  • Design your own testing framework
  • Create reusable functionality in your framework

Book Description

Selenium WebDriver is a platform-independent API for automating the testing of both browser and mobile applications. It is also a core technology in many other browser automation tools, APIs, and frameworks. This book will guide you through the WebDriver APIs that are used in automation tests.

Chapter by chapter, we will construct the building blocks of a page object model framework as you learn about the required Java and Selenium methods and terminology.

The book starts with an introduction to the same-origin policy, cross-site scripting dangers, and the Document Object Model (DOM). Moving ahead, we'll learn about XPath, which allows us to select items on a page, and how to design a customized XPath. After that, we will be creating singleton patterns and drivers. Then you will learn about synchronization and handling pop-up windows. You will see how to create a factory for browsers and understand command design patterns applicable to this area.

At the end of the book, we tie all this together by creating a framework and implementing multi-browser testing with Selenium Grid.

What you will learn

  • Understand what an XPath is and how to design a customized XPath
  • Learn how to create a Maven project and build
  • Create a Singleton driver
  • Get to grips with Jenkins integration
  • Create a factory for browsers
  • Implement multi-browser testing with Selenium Grid
  • Create a sample pop-up window and JavaScript alert
  • Report using Extent Reports

Who this book is for

This book is for software testers or developers.

Publisher Resources

Download Example Code

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Selenium WebDriver Quick Start Guide
  3. Packt Upsell
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Code in action
      4. Conventions used
    4. Get in touch
      1. Reviews
  6. Introducing Selenium WebDriver and Environment Setup
    1. Technical requirements
    2. Why is test automation required?
      1. Advantages of test automation
    3. Some pointers on Selenium
    4. What's new in Java 8
      1. Lambda expressions and functional interfaces
      2. Functional interfaces
      3. Default and static methods in an interface
      4. The forEach method for a collection
      5. Streams in Java 8
    5. Understanding Selenium RC
      1. What is cross-site scripting (XSS)?
    6. Introducing Selenium WebDriver
      1. Class structure of Selenium WebDriver
    7. Drivers in Selenium
      1. Remote WebDriver
      2. Mobile drivers
      3. Headless browsers
        1. Why do we need headless browsers?
    8. Preparing for the very first script
      1. Installing Java 8
      2. Setting up Eclipse
        1. Downloading Eclipse
        2. Creating a Maven project
        3. Understanding pom.xml
        4. Manual configuration
        5. Creating the first script
    9. Summary
  7. Understanding the Document Object Model and Creating Customized XPaths
    1. Technical requirements
    2. What is the DOM?
      1. WebElements
        1. SearchContext interface 
    3. DOM traversal
      1. Dissecting the By class
      2. The two types of XPaths
        1. Understanding customized XPaths
      3. Customized CSS
      4. An example traversal
      5. Understanding the text() methods
      6. Finding elements within the container element
      7. Best practice
      8. Extracting WebElements dynamically using tagName
        1. Properties file for WebElements
      9. Prerequisites for automating mobile applications
      10. XPaths for mobile applications
        1. Finding XPaths for mobile browser applications
          1. Connecting the actual mobile device
          2. How to use Screencast
          3. Appium Inspector window
          4. How to use UIAutomatorViewer
          5. Mobile locators
        2. What is a WebView?
    4. Introducing the Fillo API
    5. Debugging in Eclipse
    6. Summary
  8. Basic Selenium Commands and Their Usage in Building a Framework
    1. Technical requirements
    2. What are method signatures?
    3. What are Lists in java?
    4. Important methods in Selenium
      1. Some common reusable methods
    5. The difference between quit() and close()
    6. Understanding the keyword driven framework
      1. Concept of Map and HashMap
    7. Bird's eye view of the framework
      1. Introducing the testng XML file
      2. Triggering the testng XML from within the POM XML file
        1. Handling errors while running pom.xml
    8. Introducing the log4j framework
    9. Extent Reports
      1. How to use Extent Reports in code?
    10. Summary
  9. Handling Popups, Frames, and Alerts
    1. Technical requirements
    2. Window handles
      1. Fetching the window handles
        1. Understanding the Set interface
          1. A look at the iterator() method 
    3. Modal and non-modal dialog
      1. Modal and non-modal pop-up windows
      2. JavaScript and jQuery alerts
    4. Handling non-modal popup windows
      1. Introducing the switchTo() method
      2. Looking at the getTitle() method
      3. Looping through all open windows using the simple for loop
    5. Handling modal popup windows
    6. Modal and non-modal alerts
      1. Creating JavaScript and jQuery alerts
      2. Handling non-modal jQuery alerts
      3. Handling modal JavaScript alerts
    7. Understanding frames and iframes
    8. Handling mobile app permission alerts
    9. DesiredCapabilities
      1. What is a Desired Capability?
        1. The DesiredCapabilities class
          1. Enabling protected mode settings in Internet Explorer
          2. Learning Chrome options
          3. Learning the Firefox options and the Firefox profile
          4. Learning the Internet Explorer options
          5. autograntpermissions capability on Android
    10. Summary
  10. Synchronization
    1. Technical requirements
    2. What is synchronization?
      1. Synchronization types
    3. Unconditional synchronization
      1. Thread.sleep(long) 
    4. Conditional synchronization
      1. Synchronization at the WebDriver-instance level
        1. Implicit wait
      2. Synchronization at the WebElement level
        1. Explicit wait
        2. Fluent wait
          1. Function keyword
    5. A glance at the JQuery library
    6. A Sample application using JQuery
      1. Tomcat setup
        1. Exposing the JavascriptExecutor
    7. Pitfall – Never fall into one
    8. Summary
  11. The Actions Class and JavascriptExecutor
    1. Technical requirements
    2. Builder design pattern
    3. The actions class
      1. Various scenarios for the actions class
    4. Introducing JavascriptExecutor
      1. Various scenarios for JavascriptExecutor
    5. EventFiringWebDriver
    6. First steps toward the framework
    7. Understanding the Selenium Grid
      1. Architecture of the Selenium Grid
      2. Basic setup
    8. Exercise
    9. Summary
  12. The Command Pattern and Creating Components
    1. Technical requirements
    2. Introducing the command design pattern
      1. Client
      2. Invoker  
      3. Command 
      4. Receiver
    3. A look at the project structure in Eclipse
    4. Introducing the TestNG framework
      1. Installing the TestNG plugin for Eclipse
      2. A look at testng.xml
    5. Incorporating Selenium Grid
      1. Running tests in parallel
      2. Emailable report
    6. Summary
  13. Hybrid Framework
    1. Technical requirements
    2. Introducing the WebDriverManager library
      1. How to use the WebDriverManager library
        1. WebDriverManager as a Java dependency
        2. WebDriverManager as CLI
        3. WebDriverManagerServer
      2. Advantages of WebDriverManager
    3. DataProviders in TestNG
      1. Having a separate DataProvider class
    4. Introducing TestNG listeners
      1. Different types of listeners
      2. Implementing the ITestListener interface
      3. Extending the TestListenerAdapter class
    5. Introducing assertions
      1. Testing for a negative scenario
      2. Two different types of asserts 
        1. Using soft asserts
    6. Implementing logging and reporting in the framework
      1. Incorporating reporting in the framework
        1. Creating a custom XL file from testng-results.xml
        2. Adding keywords to the framework
        3. Creating reports using Fillo
    7. Generating screenshots in Selenium
    8. Using the Ashot API
    9. Some extra location techniques in Selenium WebDriver 3
      1. Understanding ByIdOrName
      2. ByAll locator
      3. ByChained Locator
    10. Welcome Selenium 4
    11. Next steps
    12. Summary
  14. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product Information

  • Title: Selenium WebDriver Quick Start Guide
  • Author(s): Pinakin Chaubal
  • Release date: October 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781789612486