Selenium Fundamentals

Book description

Discover how to use Selenium to efficiently test your own applications.

Key Features

  • Understand the importance of automation with real-world examples
  • Explore each and every path from configuring an environment to automation with Selenium Grid
  • Master the core concepts of Selenium with 40 exercises and 20 activities

Book Description

There are several challenges while writing automated tests for web applications: you have to select an adequate test framework, use appropriate selectors to avoid flaky tests, and build a good testing framework. Selenium Fundamentals helps you tackle these challenges and provides you with the knowledge to overcome hurdles in testing by developing stable and effective testing solutions. You'll learn the complete process of automated testing, such as configuring your environment, creating and running automated tests, analyzing reports, and troubleshooting errors by using a Selenium Grid.

To start with, you'll understand the importance of automating tests. You'll then move on to understanding how to choose the best selectors for navigating through your web applications while highlighting best practices and techniques.

After writing your first tests, you'll cover the object model to create your own advanced test cases. You'll analyze a test report, track timing errors, and separate real issues from flaky tests. In addition to this, you'll learn how to configure and connect to a local grid, a network grid, and a third-party service.

By the end of the book, you will have the skills you need to run automated tests on your own web applications.

What you will learn

  • Get an overview of Selenium
  • Identify what to automate in a project and configure the environment
  • Control browser behavior and manipulate web page elements
  • Understand the nuances of writing tests and creating test suites
  • Create UI tests with Selenium WebDriver and analyze test results
  • Troubleshoot errors in automation and build meaningful reporting

Who this book is for

Selenium Fundamentals is designed for you if you are a software quality assurance and development professional who wants to learn how to automate browser activity and web-based user interface tests with Selenium.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Publisher resources

View/Submit Errata

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Selenium Fundamentals
  3. Packt Upsell
    1. Why Subscribe?
    2. Packt.com
  4. Contributors
    1. About the Author
    2. 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. Conventions Used
    4. Get in Touch
      1. Reviews
  6. Getting Started
    1. Software Automation
      1. Going the Automation Way
      2. Activity: Automation Brainstorming
    2. Selenium Overview
      1. The WebDriver API
      2. The Selenium Server
        1. Selenium Glossary
      3. Activity: Selenium Planning
    3. Environment Configuration
      1. Browser Drivers
      2. Downloading and preparing browser drivers
    4. Maven Project
      1. Creating a Maven project
      2. Verifying That the Development Environment Is Ready
    5. Summary
  7. WebDriver Functionality
    1. Instantiating a WebDriver – Chrome
      1. Creating the Main Structure of Your First Selenium Automation Script
    2. An Overview of Frequently Used Methods
      1. Activity: Starting and Finalizing a Script
    3. Controlling the Browser Window
      1. Navigation
        1. Navigating in an Automation Script
      2. Resizing
        1. Resizing Windows in an Automation Script
      3. Managing Alerts
        1. Managing Alerts in an Automation Script
      4. Managing Frames and iFrames
        1. Managing Frames in an Automation Script
      5. Managing Windows
        1. Managing Windows in an Automation Script
      6. Activity: Resizing and Moving Windows with a Selenium Automation Script
    4. Summary
  8. WebElement Functionality
    1. Using Browser Developer Tools – Chrome
      1. Inspecting a Web Page with Chrome Devtools
    2. Overview of WebElement Functionality
      1. Handling the StaleElementReferenceException
    3. Interacting with Elements on a Page
      1. Interacting with Textboxes and Textareas Elements
        1. Interacting with Textboxes and Textareas During an Automation Script
      2. Interacting with Dropdown and Lists
        1. Interacting with Dropdown and Lists During an Automation Script
      3. Interacting with Radio Buttons and Radio Button Groups
        1. Interacting with Radio Buttons and Radio Buttons Groups During an Automation Script
      4. Interacting with Checkboxes
        1. Interacting with Checkboxes During an Automation Script
      5. Activity: Filling in a Form and Submitting it
    4. Element Locator Types – ID, Names, XPath, CSS, and So On
      1. Activity: Locating Elements
    5. Summary
  9. Advanced Element Location
    1. Navigating the DOM
      1. Understanding the DOM's Structure
      2. The Relationship between Selenium and the DOM
        1. Identifying Elements and Creating Locators for Dom Elements
        2. Retrieve Information from a Table
    2. Searching Within Previously Found Elements
      1. Locating Elements Based on Their Relationships
        1. Searching for Elements Through Known Elements
    3. Creating Complex Locators to Reach Any Element
      1. Common Ways to Use CSS Selectors
        1. Finding Elements by Using Class Attributes and IDs
      2. Locating Elements by Their Attributes
        1. Creating Complex Selectors for Unique Locators
      3. Activity: Automating Checkout
    4. Summary
  10. Waiting for Elements
    1. Implicit Waits
      1. Creating an Implicit Wait
    2. Explicit Waits
      1. Activity: Creating an Explicit Wait
    3. Implicit Versus Explicit Waits
    4. Waiting for an Element with a Custom Written Condition
      1. Creating Custom Waits for Finding Elements
        1. Creating a Custom Wait (Waiting for an Element)
      2. Creating Custom Waits so That an Element's Attribute Values Can Be Updated
        1. Creating a Custom Wait (Waiting for an Element's Attribute Updates)
      3. Creating Custom Waits for an Element's Visibility
        1. Creating a Custom Wait (Waiting for an Element's Visibility)
    5. Summary
  11. Page Object Model
    1. Introduction to the Page Object Model
      1. Understanding the Architecture of Web Applications
      2. Applying Web Application Architecture to Test Automation Scripts
    2. Modeling a Web Application Using Page Objects
      1. Creating a Page Object
        1. Creating a Page Object For Age Calculator
      2. Creating an Automation Script
        1. Creating an Automation Script for Age Calculator
      3. Activity: Implementing the POM on a Multi-Page Application
    3. Implementing Nested Page Object Instances
      1. Activity: Implementing Nested Page Object Instances
    4. Summary
  12. Writing Tests
    1. What is a Test Framework?
    2. Choosing a Test Framework
    3. Creating Test Scripts and Suites
      1. Annotations
      2. The TestNG.xml File
      3. Activity: Creating a TestNG Test
    4. Validating and Viewing Results
      1. Activity: Viewing the Results
    5. Summary
  13. Analysis and Troubleshooting
    1. Analyzing a Test Report
      1. General Recommendations
        1. Analyzing a Test Result
    2. Tracking Down Timing Errors
      1. How to Deal with Potential Timing Errors
        1. Tracking Down Timing Errors with Synchronization Points
    3. Separating Real Issues from Flaky Tests
      1. Identifying Flaky Tests
      2. Decreasing the Chances of Flaky Tests
    4. Summary
  14. Using a Selenium Grid
    1. Configuring and Connecting to a Local Grid
      1. Launching the Grid Hub
        1. Verifying That the Grid Hub Is Running
      2. Adding Selenium Nodes to the Grid Hub
        1. Verifying That a Selenium Instance Has Been Registered
      3. Activity: Running a Script Against a Grid Hub
    2. Configuring and Connecting to a Network Grid
      1. Adding Selenium Nodes Instances Running on Different Machines to the Grid Hub
      2. Activity: Creating a Small Selenium Grid with a Remote Node
    3. Connecting to a Third-Party Service
      1. Activity: Running a Test on a Third-party Service
    4. Summary
  15. Solutions
    1. Chapter 1: Getting Started
      1. Activity: Automation Brainstorming
      2. Activity: Selenium Planning
    2. Chapter 2: WebDriver Functionality
      1. Activity: Starting and Finalizing a Script
      2. Activity: Resizing and Moving Windows with a Selenium Automation Script
    3. Chapter 3: WebElement Functionality
      1. Activity: Filling in a Form and Submitting It
      2. Activity: Locating Elements
    4. Chapter 4: Advanced Element Location
      1. Activity: Automating Checkout
    5. Chapter 5: Waiting for Elements
      1. Activity: Creating an Explicit Wait
    6. Chapter 6: Page Object Model
      1. Activity: Implementing the POM on a Multi-Page Application
      2. Activity: Implementing Nested Page Object Instances
    7. Chapter 7: Writing Tests
      1. Activity: Creating a TestNG Test
    8. Chapter 9: Using a Selenium Grid
      1. Activity: Running a Script Against a Grid Hub
      2. Activity: Creating a Small Selenium Grid with a Remote Node
      3. Activity: Running a Test on a Third-Party Service
  16. Other Books You May Enjoy
    1. Leave a Review - Let Other Readers Know What You Think

Product information

  • Title: Selenium Fundamentals
  • Author(s): Diego Molina
  • Release date: October 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781789803815