Selenium WebDriver Practical Guide

Book Description

Creating automation test scripts for your web applications with Selenium WebDriver has never been easier thanks to this user-friendly book. All you need is a basic knowledge of Core Java, and then the practical tutorials supply the rest.

In Detail

Selenium WebDriver is an open source web UI automation tool implemented through a browser-specific browser driver, which sends commands to a browser and retrieves results.

Selenium WebDriver Practical Guide will guide you through the various APIs of WebDriver which should be used in automation tests, followed by a discussion of the various WebDriver implementations available. This guide will support you by offering you access to source code fi les, including the essential HTML fi les, that allow you to work with jQuery and other examples throughout the book. Finally, you will receive an in-depth explanation of how to deal with the latest features of WebDriver through step-by-step practical tutorials.

What You Will Learn

  • Learn the basic design of Selenium WebDriver and understand how it overcomes the limitations of its predecessor
  • Set up and use Selenium Grid
  • Discover the various mechanisms used to locate web elements
  • Perform advanced actions such as drag-and-drop, double-click, right-click, and action builders on web pages
  • Explore the advanced features of WebDriver such as handling cookies, taking screenshotsmanaging timeouts, and browser navigations
  • Acquire an understanding of the various WebDriver implementations such as Firefox Driver, IE Driver, and Chrome Driver
  • Explore WebDriver EventListeners
  • Design effective automation frameworks using the PageObject pattern
  • Learn how to deal with the latest features of WebDriver

Publisher Resources

Download Example Code

Table of Contents

  1. Selenium WebDriver Practical Guide
    1. Table of Contents
    2. Selenium WebDriver Practical Guide
    3. Credits
    4. About the Author
    5. About the Reviewers
      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
        1. Installing Java
        2. Installing Eclipse
        3. Installing Firefox
        4. Installing Firebug
        5. Installing FirePath
        6. Downloading WebDriver client library (language bindings)
        7. Downloading the Firefox Driver
      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. Introducing WebDriver and WebElements
      1. Understanding the history of Selenium
        1. Selenium 1 or Selenium Remote Control or Selenium RC
        2. Selenium 2 or Selenium WebDriver or WebDriver
        3. Differences between Selenium 1 and Selenium 2
          1. Handling the browser
          2. Having better APIs
          3. Testing mobile apps
          4. Having developer support and advanced functionalities
      2. Setting up a project in Eclipse
      3. WebElements
        1. Locating WebElements using WebDriver
          1. The findElement() method
          2. The findElements() method
          3. Firebug
          4. Using the By locating mechanism
            1. The method
            2. The method
            3. The By.tagName() method
            4. The By.className() method
            5. The By.linkText() method
            6. The By.partialLinkText() method
            7. The By.xpath() method
            8. The By.cssSelector() method
        2. Actions on WebElements
          1. The getAttribute() method
          2. The sendKeys() method
          3. The clear() method
          4. The submit() method
          5. The getCssValue() method
          6. The getLocation() method
          7. The getSize() method
          8. The getText() method
          9. The getTagName() method
          10. The isDisplayed() method
          11. The isEnabled() method
          12. The isSelected() method
      4. Summary
    9. 2. Exploring Advanced Interactions of WebDriver
      1. Understanding actions, build, and perform
        1. Learning mouse-based interactions
          1. The moveByOffset action
          2. The click at current location action
          3. The click on a WebElement action
          4. The clickAndHold at current location action
          5. The clickAndHold a WebElement action
          6. The release at current location action
          7. The release on another WebElement action
          8. The moveToElement action
          9. The dragAndDropBy action
          10. The dragAndDrop action
          11. The doubleClick at current location action
          12. The doubleClick on WebElement action
          13. The contextClick on WebElement action
          14. The contextClick at current location action
        2. Learning keyboard-based interactions
          1. The keyDown and keyUp actions
          2. The sendKeys() method
      2. Summary
    10. 3. Exploring the Features of WebDriver
      1. Setting the desired capabilities for a browser
      2. Taking screenshots
      3. Locating target windows and iFrames
        1. Switching among windows
        2. Switching among frames
        3. Handling alerts
      4. Exploring Navigate
      5. Waiting for WebElements to load
        1. Implicit wait time
        2. Explicit wait time
      6. Handling cookies
      7. Summary
    11. 4. Different Available WebDrivers
      1. FirefoxDriver
        1. Understanding the Firefox profile
          1. Adding the extension to Firefox
          2. Storing and retrieving a profile
        2. Dealing with Firefox preferences
          1. Setting preferences
          2. Understanding frozen preferences
        3. Firefox binary
          1. Installing multiple versions of Firefox
      2. InternetExplorerDriver
        1. Installing InternetExplorerDriver
        2. Writing your first test script for the IE browser
        3. Building the InternetExplorer driver service
        4. Understanding IEDriver capabilities
      3. ChromeDriver
        1. Installing ChromeDriver
        2. Writing your first test script for the Chrome browser
        3. Using ChromeOptions
      4. SafariDriver
        1. Writing your first test script for the Safari browser
      5. OperaDriver
        1. Installing OperaDriver
        2. Writing your first test script for the Opera browser
      6. Summary
    12. 5. Understanding WebDriver Events
      1. Introducing EventFiringWebDriver and EventListener classes
      2. Creating an instance of EventListener
        1. Implementing WebDriverEventListener
        2. Extending AbstractWebDriverEventListener
        3. Creating a WebDriver instance
        4. Creating EventFiringWebDriver and EventListener instances
        5. Registering EventListener with EventFiringWebDriver
        6. Executing and verifying the events
          1. Registering multiple EventListeners
      3. Exploring different WebDriver event listeners
        1. Listening for WebElement value change
        2. Listening for WebElement clicked
        3. Listening for a WebElement search event
        4. Listening for browser back navigation
        5. Listening for browser forward navigation
        6. Listening for browser navigateTo events
        7. Listening for script execution
        8. Listening for any exception
        9. Unregistering EventListener with EventFiringWebDriver
      4. Summary
    13. 6. Dealing with I/O
      1. Learning about the FileHandler class
        1. Copying files from the source to the destination directory
        2. Copying files from the source to the destination directory based on filename suffix
        3. Creating a directory
        4. Deleting a file or directory
        5. Understanding the IsZipped() method
        6. Understanding the makeExecutable() method
        7. Understanding the makeWritable() method
        8. Reading a file
        9. Understanding the canExecute() method
      2. Learning about the TemporaryFilesystem class
        1. Understanding the default temporary filesystem
        2. Creating a directory in DefaultTmpFS
        3. Deleting a temporary directory
        4. Deleting multiple files
        5. Changing the temporary filesystem
      3. Learning about the Zip class
        1. Compressing a directory
        2. Decompressing a directory
      4. Summary
    14. 7. Exploring RemoteWebDriver and WebDriverBackedSelenium
      1. Introducing RemoteWebDriver
        1. Understanding the RemoteWebDriver server
          1. Downloading the server
          2. Running the server
        2. Understanding the RemoteWebDriver client
          1. Converting an existing test script to use RemoteWebDriver server
        3. Using RemoteWebDriver for the Firefox browser
        4. Using RemoteWebDriver and the IE browser
        5. Using RemoteWebDriver and the Chrome browser
        6. Extending the RemoteWebDriver client to take screenshots
      2. Understanding the JSON wire protocol
      3. Replacing the client library with your own code
      4. Exploring WebDriverBackedSelenium
      5. Summary
    15. 8. Understanding Selenium Grid
      1. Exploring Selenium Grid
      2. Understanding the hub
      3. Understanding the node
      4. Modifying the existing test script to use Selenium Grid
        1. Requesting for nonregistered capabilities
        2. Queuing up the request if the node is busy
        3. Dealing with two nodes with matching capabilities
      5. Configuring Selenium Grid
        1. Specifying node configuration parameters
          1. Setting supported browsers by a node
          2. Setting node timeouts
          3. Setting the limit on browser instances
          4. Reregistering the node automatically
          5. Setting node health-check time
          6. Unregistering an unavailable node
          7. Setting the browser timeout
        2. Hub configuration parameters
          1. Waiting for a match of desired capability
          2. Customized CapabilityMatcher
          3. WaitTimeout for a new session
        3. Different ways to specify the configuration
      6. Summary
    16. 9. Understanding PageObject Pattern
      1. Creating test cases for our WordPress blog
        1. Test case 1 – Adding a new post to our WordPress blog
        2. Test case 2 – Deleting a post from our WordPress blog
        3. Test case 3 – Counting the number of posts on our WordPress blog
      2. What is the PageObject pattern?
        1. Using the @FindBy annotation
        2. Understanding PageFactory
      3. Good practices for the PageObjects design
        1. Consider a web page as a services provider
        2. Always look for implied services
        3. Using PageObjects within a PageObject
          1. The AddNewPost PageObject
          2. The AllPostsPage PageObject
        4. Consider methods in PageObjects as services and not as User Actions
        5. Identifying some WebElements on the fly
        6. Keeping the page-specific details off the test script
      4. Understanding loadable components
      5. Working on an end-to-end example of WordPress
        1. Looking at all the PageObjects
          1. The AdminLoginPage PageObject
          2. The AllPostsPage PageObject
          3. The AddNewPostPage PageObject
          4. The EditPostPage PageObject
          5. The DeletePostPage PageObject
        2. Looking at the test cases
          1. Adding a new post
          2. Editing a post
          3. Deleting a post
          4. Counting posts
      6. Summary
    17. 10. Testing iOS and Android Apps
      1. Different forms of mobile applications
      2. Available software tools
      3. Automating iOS and Android tests using Appium
        1. Automating iOS application tests
        2. Automating Android application tests
        3. Prerequisites for Appium
          1. Setting up Xcode
          2. Setting up Android SDK
            1. Creating Android Emulator
            2. Using real device for executing your tests
        4. Installing Appium
        5. Automating for iOS
        6. Automating for Android
      4. Summary
    18. Index

Product Information

  • Title: Selenium WebDriver Practical Guide
  • Author(s): Satya Avasarala
  • Release date: January 2014
  • Publisher(s): Packt Publishing
  • ISBN: 9781782168850