You are previewing Selenium Testing Tools Cookbook.
O'Reilly logo
Selenium Testing Tools Cookbook

Book Description

Unlock the full potential of Selenium WebDriver to test your web applications in a wide range of situations. The countless recipes and code examples provided ease the learning curve and provide insights into virtually every eventuality.

  • Learn to leverage the power of Selenium WebDriver with simple examples that illustrate real world problems and their workarounds

  • Each sample demonstrates key concepts allowing you to advance your knowledge of Selenium WebDriver in a practical and incremental way

  • Explains testing of mobile web applications with Selenium Drivers for platforms such as iOS and Android

  • In Detail

    Web technologies are becoming increasingly complex and there is 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. This book will help you test your web applications effectively and efficiently with Selenium WebDriver.

    "Selenium Testing Tools Cookbook" is an incremental guide that will help you learn and use advanced features of Selenium WebDriver API in various situations for building reliable test automation. You will learn how to effectively use features of Selenium using simple and detailed examples. This book will also teach you best practices, design patterns, and how to extend Selenium.

    "Selenium Testing Tools Cookbook" shows developers and testers who already use Selenium, how to go to the next step and build a highly maintainable and reliable test framework using advanced features of the tool.

    The book starts with tips on advanced location strategy and effective use of Selenium WebDriver API. Then it demonstrates the use of design patterns such as Data Driven Tests and PageFactory for building maintainable test automation.

    It also explains extending Selenium WebDriver API along with implementing custom tasks and setting up your own distributed environment to run tests in parallel.

    It concludes with tips on integrating Selenium WebDriver with other popular tools, testing mobile web applications, and capturing videos of test runs. This books provides examples in Java, C#, Ruby, and Python.

    "Selenium Testing Tools Cookbook" will help you in building a highly robust and maintainable test automation framework from start to finish.

    Table of Contents

    1. Selenium Testing Tools Cookbook
      1. Table of Contents
      2. Selenium Testing Tools Cookbook
      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. Locating Elements
        1. Introduction
        2. Using browser tools for inspecting elements and page structure
          1. How to do it...
          2. How it works...
        3. Locating an element using the findElement method
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Locating elements using findElements method
          1. How to do it...
          2. How it works...
          3. See also
        5. Locating links
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        6. Locating elements by tag name
          1. How to do it...
          2. How it works...
          3. See also
        7. Locating elements using CSS selectors
          1. How to do it...
            1. Performing partial match on attribute values
          2. How it works...
          3. See also
        8. Locating elements using XPath
          1. How to do it...
          2. How it works...
        9. Locating elements using text
          1. How to do it...
          2. How it works...
        10. Locating elements using advanced CSS selectors
          1. How to do it...
          2. How it works...
          3. See also
        11. Using jQuery selectors
          1. How to do it...
          2. How it works...
          3. There's more...
        12. Locating table rows and cells
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        13. Locating child elements in a table
          1. How to do it...
          2. How it works...
          3. See also
      9. 2. Working with Selenium API
        1. Introduction
        2. Checking an element's text
          1. How to do it...
          2. How it works...
          3. There's more...
        3. Checking an element's attribute values
          1. How to do it...
          2. How it works...
        4. Checking an element's CSS values
          1. How to do it...
          2. How it works...
          3. See also
        5. Using Advanced User Interactions API for mouse and keyboard events
          1. How to do it...
          2. How it works...
          3. See also
        6. Performing double-click on an element
          1. How to do it...
          2. How it works...
          3. See also
        7. Performing drag-and-drop operations
          1. How to do it...
          2. How it works...
          3. See also
        8. Executing JavaScript code
          1. How to do it...
          2. How it works...
          3. There's more...
        9. Capturing screenshots with Selenium WebDriver
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        10. Capturing screenshots with RemoteWebDriver/Grid
          1. Getting ready
          2. How to do it...
          3. How it works...
        11. Maximizing the browser window
          1. Getting ready
          2. How to do it...
          3. How it works...
        12. Automating dropdowns and lists
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        13. Checking options in dropdowns and lists
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        14. Checking selected options in dropdowns and lists
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        15. Automating radio buttons and radio groups
          1. How to do it...
          2. How it works...
        16. Automating checkboxes
          1. How to do it...
          2. How it works...
        17. Controlling Windows processes
          1. How to do it...
          2. How it works...
        18. Reading a Windows registry value from Selenium WebDriver
          1. How to do it...
          2. How it works...
          3. See also
        19. Modifying a Windows registry value from Selenium WebDriver
          1. How to do it...
          2. How it works...
          3. See also
      10. 3. Controlling the Test Flow
        1. Introduction
          1. Pop ups and Alerts
        2. Synchronizing a test with an implicit wait
          1. How to do it...
          2. How it works...
          3. See also
        3. Synchronizing a test with an explicit wait
          1. How to do it...
          2. How it works...
          3. See also
        4. Synchronizing a test with custom-expected conditions
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Waiting for element's attribute value update
            2. Waiting for an element's visibility
            3. Waiting for DOM events
        5. Checking an element's presence
          1. How to do it...
          2. How it works...
          3. See also
        6. Checking an element's status
          1. How to do it...
          2. How it works...
        7. Identifying and handling a pop-up window by its name
          1. How to do it...
          2. How it works...
          3. There is more...
            1. NoSuchWindowException
          4. See also
        8. Identifying and handling a pop-up window by its title
          1. How to do it...
          2. How it works...
          3. See also
        9. Identifying and handling a pop-up window by its content
          1. How to do it...
          2. How it works...
          3. See also
        10. Handling a simple JavaScript alert
          1. How to do it...
          2. How it works...
          3. There is more...
            1. NoAlertPresentException
          4. See also
        11. Handling a confirm box alert
          1. How to do it...
          2. How it works...
          3. See also
        12. Handling a prompt box alert
          1. How to do it...
          2. How it works...
          3. See also
        13. Identifying and handling frames
          1. How to do it...
          2. How it works...
          3. See also
        14. Identifying and handling frames by their content
          1. How to do it...
          2. How it works...
          3. See also
        15. Working with IFRAME
          1. How to do it...
          2. How it works...
          3. See also
      11. 4. Data-driven Testing
        1. Introduction
          1. Data-driven approach – workflow
          2. Benefits of data-driven testing
        2. Creating a data-driven test using JUnit
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        3. Creating a data-driven test using TestNG
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Reading test data from a CSV file using JUnit
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Reading test data from an Excel file using JUnit and Apache POI
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Reading test data from a database using JUnit and JDBC
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Creating a data-driven test in NUnit
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        8. Creating a data-driven test in MSTEST
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        9. Creating a data-driven test in Ruby using Roo
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        10. Creating a data-driven test in Python
          1. How to do it...
          2. How it works...
      12. 5. Using the Page Object Model
        1. Introduction
        2. Using the PageFactory class for exposing elements from a page
          1. Getting ready
          2. How to do it...
          3. How it works...
            1. FindBy annotations
            2. CacheLookUp Attribute
        3. Using the PageFactory class for exposing an operation on a page
          1. Getting ready
          2. How to do it...
          3. How it works...
        4. Using the LoadableComponent class
          1. Getting ready
          2. How to do it...
          3. How it works...
        5. Implementing nested Page Object instances
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Implementing the Page Object model in .NET
          1. Getting ready
          2. How to do it...
          3. How it works...
        7. Implementing the Page Object model in Python
          1. Getting ready
          2. How to do it...
          3. How it works...
        8. Implementing the Page Object model in Ruby by using the page-object gem
          1. Getting ready
          2. How to do it...
          3. How it works...
      13. 6. Extending Selenium
        1. Introduction
        2. Creating an extension class for web tables
          1. Getting ready
          2. How to do it...
          3. How it works...
        3. Creating an extension for the jQueryUI Tab widget
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Implementing an extension for the WebElement object to set the element attribute values
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Implementing an extension for the WebElement object to highlight elements
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Creating an object map for Selenium tests
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
        7. Capturing screenshots of elements in the Selenium WebDriver
          1. How to do it...
          2. How it works...
          3. See also
        8. Comparing images in Selenium
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      14. 7. Testing on Mobile Browsers
        1. Introduction
        2. Setting up the iWebDriver App for the iPhone/iPad simulator
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Setting up the iWebDriver App for an iPhone/iPad device
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. Running tests on iOS using the iWebDriver App and iPhone driver
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Setting up the Android emulator for Selenium
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Setting up the Android device for Selenium
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Running tests using AndroidDriver
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Running the test with RemoteWebDriver
      15. 8. Client-side Performance Testing
        1. Introduction
        2. Measuring the response time using a timer
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. StopWatch in .NET bindings
          5. See also
        3. Measuring performance with the Navigation Timing API
          1. Getting ready
          2. How to do it...
          3. How it works...
        4. Using the BrowserMob proxy for measuring performance
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Using dynaTrace for measuring the performance
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Using HttpWatch for measuring performance
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Client-side performance testing with Watir-WebDriver-Performance in Ruby
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      16. 9. Testing HTML5 Web Applications
        1. Introduction
        2. Automating the HTML5 video player
          1. How to do it...
          2. How it works...
            1. Video playback
          3. See also
        3. Automating interaction on the HTML5 canvas element
          1. How to do it...
          2. How it works...
          3. See also
        4. Web storage – testing local storage
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Web storage – testing session storage
          1. How to do it...
          2. How it works...
          3. See also
        6. Cleaning local and session storage
          1. How it works...
          2. See also
      17. 10. Recording Videos of Tests
        1. Introduction
        2. Recording videos of tests using Monte Media Library in Java
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Recording videos of tests using Microsoft Expression Encoder 4 SDK in .NET
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Recording videos of tests using Castro in Python
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      18. 11. Behavior-driven Development
        1. Introduction
        2. Using Cucumber-JVM and Selenium WebDriver in Java for BDD
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
          5. See also
        3. Using SpecFlow.NET and Selenium WebDriver in .NET for BDD
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. Using JBehave and Selenium WebDriver in Java
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Using Capybara, Cucumber, and Selenium WebDriver in Ruby
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
      19. Index