You are previewing Learning Selenium Testing Tools - Third Edition.
O'Reilly logo
Learning Selenium Testing Tools - Third Edition

Book Description

Leverage the power of Selenium to build your own real-time test cases from scratch

In Detail

Web technologies are becoming increasingly complex and there is often a need to test your web applications against a vast number of browsers and platforms, so you need to build highly reliable and maintainable test automation cases. Selenium is one of the most easy to implement and efficient solutions for this.

This book will guide you through designing and implementing the automation framework on Selenium to build advanced automated test cases. You will start with getting acquainted with the Selenium IDE, working with AJAX, and using different methods to locate elements in a web page. You will then move on to using PageObjects, making tests maintainable, using WebDriver with different browsers, and setting up Selenium Grid. You will also be introduced to advanced topics such as working with proxy servers, network intrusions, and more. By the end of the book, you will have the skills to efficiently test your web applications using Selenium. A well-detailed section has been dedicated to teaching you the object-oriented concepts with basics of core Java, which are the pre-requisites for Selenium automation.

What You Will Learn

  • Understand designing and implementing the automation framework

  • Understand and implement AJAX in your web pages

  • Set up Selenium WebDriver in both IntelliJ and Eclipse

  • Build test suites in Selenium using PageObjects

  • Get to know about WebElement handling with Selenium WebDriver

  • Install Selenium WebDriver for mobile devices

  • Understand and learn testing in Selenium Grid

  • 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.

    Table of Contents

    1. Learning Selenium Testing Tools Third Edition
      1. Table of Contents
      2. Learning Selenium Testing Tools Third Edition
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Getting Started with Selenium IDE
        1. Understanding Selenium IDE
          1. Installing Selenium IDE
          2. Getting acquainted with the Selenium IDE tool
        2. Rules in creating tests with Selenium IDE
        3. Recording your first test with Selenium IDE
        4. Validating a test with assert and verify
        5. Creating comments in your tests
          1. Adding Selenium IDE comments
        6. Multiplying windows
          1. Working with multiple windows
          2. Complex working with multiple windows
        7. Selenium tests against AJAX applications
          1. Working on pages with AJAX
          2. Working with AJAX applications
        8. Storing information from the page in the test
        9. Debugging tests
        10. Creating test suites
        11. Parameterization
          1. Selenium IDE Configuration
          2. Generating source code from Selenium IDE
        12. Saving tests
        13. What you cannot record
        14. Summary
        15. Self-test questions
      9. 2. Locators
        1. Locating elements by ID
          1. Finding IDs of elements on the page with Firebug
          2. Finding elements by ID
        2. Moving elements on the page
          1. Finding elements by name
            1. Adding filters to the name
          2. Finding elements by link text
          3. Finding elements by accessing the DOM via JavaScript
          4. Finding elements by XPath
        3. Using direct XPath in your test
          1. Finding elements by direct XPath
          2. Using XPath to find the nth element of a type
          3. Using element attributes in XPath queries
          4. Performing partial match on attribute content
          5. Finding an element by the text it contains
        4. Leveraging the XPath axis with elements
          1. Using the XPath axis
        5. CSS selectors
          1. Finding elements by CSS
          2. Using child nodes to find the element
          3. Using sibling nodes to find the element
          4. Using CSS class attributes in CSS selectors
          5. Using element IDs in CSS selectors
        6. Working with elements and their attributes
          1. Finding elements by their attributes
          2. Performing partial matches on attributes content
          3. Finding the nth element with CSS
          4. Finding an element by its inner text or partial text
        7. Summary
        8. Self-test questions
      10. 3. Overview of the Selenium WebDriver
        1. History of Selenium
        2. Understanding the WebDriver architecture
          1. The WebDriver API
          2. The WebDriver SPI
          3. The JSON Wire Protocol
          4. The Selenium server
        3. Merging of two projects
          1. Setting up the IntelliJ IDEA project
        4. Setting up Eclipse IDE with Java project for Selenium WebDriver and TestNG
          1. Downloading WebDriver JAR files
          2. Downloading and installing Eclipse
          3. Configuring WebDriver with Eclipse
          4. TestNG plug-in installation for Eclipse
            1. Steps for installation
        5. Summary
        6. Self-test questions
      11. 4. Finding Elements
        1. Finding elements
          1. Finding an element on the page by its ID
            1. Using findElementById()
          2. Finding elements on the page by their ID
            1. Using findElementsById()
          3. Finding an element on the page by its name
            1. Using findElementByName()
          4. Finding elements on the page by their name
            1. Using findElementsByName()
          5. Finding an element on the page by its ClassName
            1. Using findElementByClassName()
          6. Finding elements on the page by their ClassName
            1. Using findElementsByClassName()
          7. Finding an element on the page by its XPath
            1. Using findElementByXPath()
          8. Finding elements on the page by their XPath
            1. Using findElementsByXpath()
          9. Finding an element on the page by its link text
            1. Using findElementByLinkText()
          10. Finding elements on the page by their link text
            1. Using findElementsByLinkText()
        2. Using findElement Helper methods
        3. Finding elements using a more generic method
          1. Using findElement()
          2. Using findElements()
        4. Tips and tricks
          1. Finding if an element exists without throwing an error
        5. Waiting for elements to appear on the page
          1. Implicit waits
            1. Using implicit waits
          2. Explicit waits
            1. Using explicit waits with Selenium WebDriver
        6. Summary
        7. Self-test questions
      12. 5. Design Patterns
        1. Page objects
          1. Setting up the test
          2. Moving Selenium steps into private methods to make tests maintainable
          3. Using the Page Object pattern to design tests
        2. Using Page Factory with Page Object
          1. Using PageFactory
          2. LoadableComponent
        3. Changing our Page Object to use LoadableComponent
        4. Using LoadableComponent
        5. Summary
        6. Self-test questions
      13. 6. Working with WebDriver
        1. Working with FirefoxDriver
          1. Firefox profile preferences
          2. Installing a Firefox add-on
        2. Working with ChromeDriver
          1. ChromeOptions
        3. Working with OperaDriver
          1. OperaProfile
        4. Working with InternetExplorerDriver
        5. Other important points
        6. Summary
        7. Self-test questions
      14. 7. Automation Framework Development and Building Utilities
        1. Automation without framework
        2. Automation with Framework
        3. Test Automation Frameworks Evolution
          1. Record/Playback
            1. Advantages
            2. Disadvantages
          2. Action driven approach
            1. Advantages
            2. Disadvantages
          3. Data driven approach
            1. Advantages
            2. Disadvantages
          4. Keyword driven method
            1. Advantages
            2. Disadvantages
          5. Hybrid
            1. Environment specifications
            2. Hybrid architecture design
            3. The automation framework structure
            4. The project folder structure
            5. Adding a keyword to a Selenium automation framework
        4. Form an automated test case using keywords
          1. Steps to form an automated test case
        5. Building your own utilities for the Selenium automation framework
          1. Configuration and usage of the framework
          2. Run the automation suite
            1. Execution starts and ends
        6. Summary
        7. Self-test questions
      15. 8. Mobile Devices
        1. Working with Android
          1. Emulator
          2. Creating an emulator
          3. Installing the Selenium WebDriver Android Server
          4. Installing the Android Server
          5. Creating a test for Android
          6. Using the Android driver
        2. Running with OperaDriver on a mobile device
        3. Using OperaDriver on Opera Mobile
        4. Working with iOS
          1. Setting up the simulator
          2. Setting up on a real device
          3. Creating a test for iOS devices
          4. Using the iPhone driver
        5. Summary
        6. Self-test questions
      16. 9. Getting Started with the Selenium Grid
        1. Understanding Selenium Grid
        2. The Selenium Grid hub
          1. Launching the hub
        3. Adding instances to the hub
          1. Adding a server with the defaults
        4. Adding Selenium Remote Control for different machines
          1. Selenium Server for different machines
        5. Adding Selenium Server to do specific browser tasks on specific operating systems
          1. Setting the environment when starting Selenium Remote Control
          2. Using Selenium Grid 1 with your YAML file
          3. Using Selenium Grid 1 configuration
        6. Running tests against the grid
          1. Writing tests against the grid
        7. Running tests in parallel
          1. Getting our tests running in parallel
        8. Summary
        9. Self-test questions
      17. 10. Advanced User Interactions
        1. What is Advanced User Interactions API?
          1. Keyboard
          2. Mouse
        2. The Actions class
          1. Drag and drop
            1. Creating an Actions method chain for dragging and dropping
          2. Moving an element to an offset
            1. Moving an element with a drag and drop by offset
          3. The context click
            1. Doing a context click
          4. Clicking on multiple items in a select element
            1. Selecting multiple items on a select item
          5. Clicking and holding down the mouse
            1. Holding the mouse button down while moving the mouse
        3. Summary
        4. Self-test questions
      18. 11. Working with HTML5
        1. Working with application cache
          1. Getting the current status of application cache
        2. Interacting with browser connections
          1. Seeing if the browser is online
            1. Checking the browser status
          2. Setting the browser offline or online
            1. Setting the browser connection
        3. Working with WebStorage
          1. Local storage
            1. Accessing localStorage
          2. Session storage
            1. Accessing sessionStorage
        4. Summary
        5. Self-test questions
      19. 12. Advanced Topics
        1. Capturing screenshots
          1. Capturing the base64 version of images
            1. Image capturing as base64 strings
          2. Saving the screenshot to bytes
            1. Saving images to bytes
            2. Saving a screenshot to file
        2. Using XVFB with Selenium
          1. Setting up XVFB server
          2. Running tests in XVFB
        3. Working with BrowserMob Proxy
          1. Creating and starting a proxy
          2. Capturing network traffic
        4. Summary
        5. Self-test questions
      20. 13. Migrating from Remote Control to WebDriver
        1. WebDriverBackedSelenium
          1. Converting tests to Selenium WebDriver using WebDriverBackedSelenium
        2. Summary
        3. Self-test question
      21. A. Automation Prerequisites for Selenium Automation
        1. About Java programming
          1. How does Java work?
            1. Package
            2. Class
            3. Objects
            4. Importing the sample Java project in the Eclipse workspace
          2. A simple Java program example
        2. Inheritance
          1. A Java program with an inheritance example
            1. An abstract class
          2. An example of a Java program with an abstract class
        3. Polymorphism
          1. Overloading
            1. An example of a Java program with overloading
          2. Overriding
            1. An example of a Java program with overriding
        4. Encapsulation
          1. An example of a Java program using encapsulation
        5. Constructors
          1. An example of a Java program with a constructor chain
        6. Interface
          1. An example of a Java program with an interface
            1. Abstract classes compared with interfaces
          2. The this keyword
        7. Data types and variables in Java
          1. Data types
          2. Variables
            1. Local variables
            2. Instance variables
            3. Class/static variables
          3. Type casting
            1. Widening
            2. Narrowing
              1. Example on widening and narrowing
        8. Java operators
          1. A simple assignment operator
          2. Arithmetic operators
          3. Unary operators
          4. Equality and relational operators
          5. Conditional operators
          6. Type comparison operator
          7. Bitwise and bit shift operators
          8. Operator precedence
        9. Decision and control statements
          1. The if statement
          2. The if...else statement
          3. The if...else if...else statement
          4. The nested if...else statement
          5. The switch statement
        10. Loops
          1. The while loop
          2. The do...while loop
          3. The for loop
            1. The for each loop in Java
          4. The break keyword
          5. The continue keyword
        11. String class functions
          1. The charAt() function
          2. The equalsIgnoreCase() function
          3. The length() function
          4. The replace() function
          5. The substring() function
          6. The toLowerCase() function
          7. The toUpperCase() function
          8. The trim() function
        12. Collections
          1. What is a Collections framework?
        13. Exception handling
          1. Types of exceptions
          2. Exception handler components
          3. The throw keyword
          4. Java IO
            1. The FileOutputStream class
            2. The FileInputStream class
        14. Java coding standards
          1. Why are coding standards required?
        15. Summary
        16. Self-test Questions
      22. B. Answers for Self-test Questions
        1. Chapter 1
        2. Chapter 2
        3. Chapter 3
        4. Chapter 4
        5. Chapter 5
        6. Chapter 6
        7. Chapter 7
        8. Chapter 8
        9. Chapter 9
        10. Chapter 10
        11. Chapter 11
        12. Chapter 12
        13. Chapter 13
        14. Appendix A
      23. Index