You are previewing Selenium 2 Testing Tools Beginner's Guide.
O'Reilly logo
Selenium 2 Testing Tools Beginner's Guide

Book Description

Testing web applications using Selenium is made simple with this tutorial. Written for those with no prior experience, it helps you learn through practical exercises and code samples. The perfect entry point to Selenium 2.

  • Automate web browsers with Selenium WebDriver to test web applications

  • Set up Java Environment for using Selenium WebDriver

  • Learn good design patterns for testing web applications

  • In Detail

    Selenium automates browsers. It is primarily used for automating web applications for testing purposes.

    Selenium has the support of some of the largest browser vendors who have taken (or are taking) steps to make Selenium a native part of their browser. It is also the core technology in countless other browser automation tools, APIs and frameworks.

    "Selenium 2 Testing Tools: Beginner’s Guide" will help you begin with testing web applications using Selenium from scratch. From setting up the Java environment to running tests on mobile devices, it contains all the information to get a novice up and running on using Selenium.

    You will also learn some advanced concepts such as testing complex web applications and running tests in parallel towards the end of the book.

    This book is your answer to getting started with Selenium.

    This is a good technical book that walks readers through how to break down a web application to being confident to automate your favorite web application.

    You start with installing Selenium and the basics, and then move on to using Selenium IDE for bug replication. An overview of the WebDriver is presented next followed by migrating your tests from Selenium RC to Selenium WebDriver. You will then learn to find elements on a webpage from both the driver object as well as the element object and work with the Firefox driver. You will scan through mobile support and Selenium Grid. Design patterns and advanced topics are also covered.

    By the end of the book, you will feel extremely confident with tackling websites on a number of different platforms.

    Table of Contents

    1. Selenium 2 Testing Tools Beginner's Guide
      1. Selenium 2 Testing Tools Beginner's Guide
      2. Credits
      3. About the Author
      4. About the Reviewers
      5. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      6. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Time for action – heading
          1. What just happened?
          2. Pop quiz – heading
          3. Have a go hero – heading
        6. Reader feedback
        7. Customer support
          1. Errata
          2. Piracy
          3. Questions
      7. 1. Getting Started with Selenium IDE
        1. Important preliminary points
        2. What is Selenium IDE
        3. Time for action – installing Selenium IDE
          1. What just happened?
        4. Selenium IDE
        5. Important note: Rules for automation
        6. Time for action – recording your first test with Selenium IDE
          1. What just happened?
          2. Pop quiz – Selenium IDE
        7. Updating a test to assert items are on the page
        8. Time for action – updating a test to verify items on the page
          1. What just happened?
          2. Have a go hero – recreating the test by using the assert methods
          3. Pop quiz – verifying and asserting
        9. Comments
        10. Time for action – adding Selenium IDE comments
          1. What just happened?
        11. Multiplying windows
        12. Time for action – working with multiple windows
          1. What just happened?
        13. Time for action – complex working with multiple windows
          1. What just happened?
        14. Selenium tests against AJAX applications
        15. Time for action – working on pages with AJAX
          1. What just happened?
        16. Time for action – working with AJAX applications
          1. What just happened?
          2. Pop quiz – waiting for elements
        17. Storing information from the page in the test
        18. Time for action – storing elements from the page
          1. What just happened?
        19. Debugging tests
        20. Time for action – debugging tests
          1. What just happened?
        21. Test Suites
        22. Time for action – creating Test Suites
          1. What just happened?
          2. Pop quiz – Test Suites
        23. Saving tests
        24. What you cannot record
        25. Summary
      8. 2. Locators
        1. Important preliminary points
        2. Locating elements by ID
        3. Time for action - finding IDs of elements on the page with Firebug
          1. What just happened?
          2. Pop quiz – using the Find button
        4. Time for action - finding elements by ID
          1. What just happened?
        5. Moving elements on the page
        6. Time for action - finding elements by name
          1. What just happened?
        7. Adding filters to the name
        8. Time for action - finding elements by link text
          1. What just happened?
        9. Time for action - finding elements by accessing the DOM via JavaScript
          1. What just happened?
          2. Pop quiz – finding Elements with DOM JavaScript
        10. Time for action - finding elements by XPath
          1. What just happened?
          2. Using direct XPath in your test
        11. Time for action – finding elements by direct XPath
          1. What just happened?
          2. Using XPath to find the nth element of a type
          3. Using element attributes in XPath queries
          4. Doing a partial match on attribute content
          5. Finding an element by the text it contains
        12. Using XPath Axis to find elements
        13. Time For Action – using XPath Axis
          1. What just happened?
          2. Pop quiz – using XPath Axis
          3. Have a go hero – working with XPath Axis
        14. CSS selectors
        15. Time for action - finding elements by CSS
          1. What just happened?
          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. Finding elements by their attributes
          7. Partial matches on attributes
        16. Time for action – finding the nth element with CSS
          1. What just happened?
          2. Finding an element by its inner text
          3. Pop quiz – using locators
          4. Have a go hero – working against Google Maps
        17. Summary
      9. 3. Overview of Selenium WebDriver
        1. Important preliminary points
        2. History of Selenium
        3. Architecture
          1. WebDriver API
          2. WebDriver SPI
          3. JSON Wire protocol
          4. Selenium server
          5. The merging of two projects
        4. How to set up your Java environment
        5. Time for action – setting up Intellij IDEA project
          1. What just happened?
          2. Pop quiz – setting up the test project
        6. Summary
      10. 4. Design Patterns
        1. Important preliminary points
        2. Page Objects
        3. Time for action – setting up the test
          1. What just happened?
        4. Time for action – moving Selenium steps into private methods to make tests maintainable
          1. What just happened?
        5. Time for action – using the Page Object Pattern to design tests
          1. What just happened?
          2. Pop quiz – Page Object design pattern
        6. Using Page Factories with Page Objects
        7. Time for action – using PageFactory
          1. What just happened?
          2. Pop quiz – Page Factories
        8. LoadableComponent
        9. Time for action – changing our Page Object to use LoadableComponent
          1. What just happened?
          2. Have a go hero – LoadableComponent
        10. Summary
      11. 5. Finding Elements
        1. Important preliminary points
        2. Finding elements
          1. Finding an element on the page by its ID
        3. Time for action – using findElementById()
          1. What just happened?
          2. Finding elements on the page by their ID
        4. Time for action – using findElementsById()
          1. What just happened?
          2. Finding an element on the page by its name
        5. Time for action – using findElementByName()
          1. What just happened?
          2. Finding elements on the page by their name
        6. Time for action – using findElementsByName()
          1. What just happened?
          2. Finding an element on the page by their ClassName
        7. Time for action – using findElementByClassName()
          1. What just happened?
          2. Finding elements on the page by their ClassName
        8. Time for action – using findElementsByClassName()
          1. What just happened?
          2. Finding an element on the page by their XPath
        9. Time for action – using findElementByXPath()
          1. What just happened?
          2. Finding elements on the page by their XPath
        10. Time for action – using findElementsByXpath()
          1. What just happened?
          2. Finding an element on the page by its link text
        11. Time for action – using findElementByLinkText()
          1. What just happened?
          2. Finding elements on the page by their link text
        12. Time for action – using findElementsByLinkText()
          1. What just happened?
          2. Pop quiz – finding elements using helper methods
          3. Have a go hero – using findElement Helper methods
        13. Finding elements using a more generic method
        14. Time for action – using findElement()
          1. What just happened?
        15. Time for action – using findElements()
          1. What just happened?
        16. Tips and tricks
          1. Finding if an element exists without throwing an error
          2. Waiting for elements to appear on the page
            1. Implicit waits
        17. Time for action – using implicit waits
          1. What just happened?
            1. Explicit waits
        18. Time for action – using explicit waits with Selenium WebDriver
          1. What just happened?
        19. Summary
      12. 6. Working with WebDriver
        1. Important preliminary points
        2. Working with FirefoxDriver
        3. Time for action – loading the FirefoxDriver
          1. What just happened?
          2. Firefox profile preferences
        4. Time for action – setting Firefox preferences
          1. What just happened?
          2. Installing a Firefox add-on
        5. Time for action – installing the add-on
          1. What just happened?
          2. Pop quiz – working with FirefoxDriver
          3. Have a go hero – installing Firebug and not loading the First Run page
        6. Working with ChromeDriver
        7. Time for action – starting Google Chrome or Chromium
          1. What just happened?
          2. ChromeOptions
        8. Time for action – using ChromeOptions
          1. What just happened?
          2. Pop quiz – using ChromeDriver
        9. Working with OperaDriver
        10. Time for action – starting Opera
          1. What just happened?
          2. OperaProfile
        11. Time for action – working with OperaProfile
          1. What just happened?
          2. Pop quiz – working with OperaDriver
        12. Working with InternetExplorerDriver
        13. Time for action – working with Internet Explorer
          1. What just happened?
          2. Pop quiz – working with InternetExplorerDriver
        14. Other important points
        15. Summary
      13. 7. Mobile Devices
        1. Important preliminary points
        2. Working with Android
          1. Emulator
        3. Time for action – creating an emulator
          1. What just happened?
          2. Installing the Selenium WebDriver Android Server
        4. Time for action – installing the Android Server
          1. What just happened?
          2. Creating a test for Android
        5. Time for action – using the Android driver
          1. What just happened?
          2. Pop quiz – working with Android
          3. Have a go hero – updating tests for Android
        6. Running with OperaDriver on a mobile device
        7. Time for action – using OperaDriver on Opera Mobile
          1. What just happened?
        8. Working with iOS
        9. Time for action – setting up the simulator
          1. What just happened?
        10. Time for action – setting up on a real device
          1. What just happened?
          2. Creating a test for iOS devices
        11. Time for action – using the iPhone driver
          1. What just happened?
          2. Have a go hero – updating tests for iOS Devices
        12. Summary
      14. 8. Getting Started with Selenium Grid
        1. Understanding Selenium Grid
        2. Selenium Grid Hub
        3. Time for action – launching the hub
          1. What just happened?
        4. Adding instances to the hub
        5. Time for action – adding a server with the defaults
          1. What just happened?
        6. Adding Selenium Remote Controls for different machines
        7. Time for action – adding Selenium server for different machines
          1. What just happened?
        8. Adding Selenium server to do specific browser tasks on specific operating systems
        9. Time for action – setting the environment when starting Selenium Remote Control
          1. What just happened?
        10. Using Selenium Grid 2 with your YAML file
        11. Time for action – using Selenium Grid 1 configuration
          1. What just happened?
          2. Pop quiz – using Selenium Grid 2
        12. Running tests against the grid
        13. Time for action – writing tests against the grid
          1. What just happened?
        14. Running tests in parallel
        15. Time for action – getting our tests running in parallel
          1. What just happened?
        16. Summary
      15. 9. Advanced User Interactions
        1. Important preliminary points
        2. What is the Advanced User Interactions
          1. Keyboard
          2. Mouse
        3. Actions
          1. Drag and drop
        4. Time for action – creating an Actions chain for dragging and dropping
          1. What just happened?
          2. Moving an element to an offset
        5. Time for action – moving an element with a drag-and-drop by offset
          1. What just happened?
          2. Doing a context click
        6. Time for action – doing a context click
          1. What just happened?
          2. Clicking on multiple items in a select element
        7. Time for action – selecting multiple items on a select item
          1. What just happened?
          2. Holding the mouse button down while moving the mouse
        8. Time for action – holding the mouse button down while moving the mouse
          1. What just happened?
          2. Pop quiz – using Action Chains
        9. Summary
      16. 10. Working with HTML5
        1. Important preliminary points
        2. Working with application cache
        3. Time for action – getting the current status of application cache
          1. What just happened?
        4. Interacting with browser connections
          1. Seeing if the browser is online
        5. Time for action – seeing if the browser is online
          1. What just happened?
          2. Setting the browser offline or online
        6. Time for action – setting the browser connection to offline or online
          1. What just happened?
        7. Working with WebStorage
          1. Local storage
        8. Time for action – accessing localStorage
          1. What just happened?
          2. Session storage
        9. Time for action – accessing sessionStorage
          1. What just happened?
        10. Summary
      17. 11. Advanced Topics
        1. Important preliminary points
        2. Capturing screenshots
          1. Capturing base64 version of images
        3. Time for action – capturing images as base64 strings
          1. What just happened?
          2. Saving the screenshot to bytes
        4. Time for action – saving images to bytes
          1. What just happened?
          2. Saving screenshots to files
        5. Time for action – saving a screenshot to file
          1. What just happened?
          2. Pop quiz – saving screenshots
        6. Using XVFB with Selenium
        7. Time for action – setting up XVFB server
          1. What just happened?
          2. Running tests in XVFB
        8. Time for action – running tests with XVFB
          1. What just happened?
          2. Pop quiz – using XVFB
          3. Have a go hero – running tests in parallel with XVFB
        9. Working with BrowserMob Proxy
          1. Creating a proxy
        10. Time for action – starting the proxy
          1. What just happened?
          2. Capturing network traffic
        11. Time for action – capturing network traffic
          1. What just happened?
          2. Pop quiz – capturing Network Traffic
          3. Have a go hero – doing more with BrowserMob Proxy
        12. Summary
      18. A. Migrating from Remote Control to WebDriver
        1. WebDriverBackedSelenium
        2. Time for action – converting tests to Selenium WebDriver using WebDriverBackedSelenium
          1. What just happened?
          2. Pop quiz – how do you use WebDriverBackedSelenium
        3. Summary
      19. B. Pop Quiz Answers
        1. Chapter 1
          1. Pop quiz – Selenium IDE
          2. Pop quiz – verifying and asserting
          3. Pop quiz – waiting for elements
          4. Pop quiz – Test Suites
        2. Chapter 2
          1. Pop quiz – using the Find button
          2. Pop quiz – finding Elements with DOM JavaScript
          3. Pop quiz – using XPath Axis
          4. Pop quiz – using locators
        3. Chapter 3
          1. Pop quiz – setting up the test project
        4. Chapter 4
          1. Pop quiz – Page Object design pattern
          2. Pop quiz – Page Factories
        5. Chapter 5
          1. Pop quiz – finding elements using helper methods
        6. Chapter 6
          1. Pop quiz – working with FirefoxDriver
          2. Pop quiz – using ChromeDriver
          3. Pop quiz – working with OperaDriver
          4. Pop quiz – working with InternetExplorerDriver
        7. Chapter 7
          1. Pop quiz – working with Android
        8. Chapter 8
          1. Pop quiz – using Selenium Grid 2
        9. Chapter 9
          1. Pop quiz – using Action Chains
        10. Chapter 11
          1. Pop quiz – saving screenshots
          2. Pop quiz – using XVFB
          3. Pop quiz – capturing Network Traffic
        11. Appendix A
          1. Pop quiz – how do you use WebDriverBackedSelenium