Selenium 2 Testing Tools: Beginner’s Guide


Selenium 2 Testing Tools: Beginner’s Guide
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.94
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • 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

Book Details

Language : English
Paperback : 232 pages [ 235mm x 191mm ]
Release Date : October 2012
ISBN : 1849518300
ISBN 13 : 9781849518307
Author(s) : David Burns
Topics and Technologies : All Books, Web Development, Beginner's Guides, Open Source

Table of Contents

Preface
Chapter 1: Getting Started with Selenium IDE
Chapter 2: Locators
Chapter 3: Overview of Selenium WebDriver
Chapter 4: Design Patterns
Chapter 5: Finding Elements
Chapter 6: Working with WebDriver
Chapter 7: Mobile Devices
Chapter 8: Getting Started with Selenium Grid
Chapter 9: Advanced User Interactions
Chapter 10: Working with HTML5
Chapter 11: Advanced Topics
Appendix A: Migrating from Remote Control to WebDriver
Appendix B: Pop Quiz Answers
Index
  • Chapter 1: Getting Started with Selenium IDE
    • Important preliminary points
    • What is Selenium IDE
    • Time for action – installing Selenium IDE
    • Selenium IDE
    • Important note: Rules for automation
    • Time for action – recording your first test with Selenium IDE
    • Updating a test to assert items are on the page
    • Time for action – updating a test to verify items on the page
    • Comments
    • Time for action – adding Selenium IDE comments
    • Multiplying windows
    • Time for action – working with multiple windows
    • Time for action – complex working with multiple windows
    • Selenium tests against AJAX applications
    • Time for action – working on pages with AJAX
    • Time for action – working with AJAX applications
    • Storing information from the page in the test
    • Time for action – storing elements from the page
    • Debugging tests
    • Time for action – debugging tests
    • Test Suites
    • Time for action – creating Test Suites
    • Saving tests
    • What you cannot record
    • Summary
    • Chapter 2: Locators
      • Important preliminary points
      • Locating elements by ID
      • Time for action - finding IDs of elements on the page with Firebug
      • Time for action - finding elements by ID
      • Moving elements on the page
      • Time for action - finding elements by name
      • Adding filters to the name
      • Time for action - finding elements by link text
      • Time for action - finding elements by accessing the DOM via JavaScript
      • Time for action - finding elements by XPath
        • Using direct XPath in your test
      • Time for action – finding elements by direct XPath
        • Using XPath to find the nth element of a type
        • Using element attributes in XPath queries
        • Doing a partial match on attribute content
        • Finding an element by the text it contains
      • Using XPath Axis to find elements
      • Time For Action – using XPath Axis
      • CSS selectors
      • Time for action - finding elements by CSS
        • Using child nodes to find the element
        • Using sibling nodes to find the element
        • Using CSS class attributes in CSS selectors
        • Using element IDs in CSS selectors
        • Finding elements by their attributes
        • Partial matches on attributes
      • Time for action - finding the nth element with CSS
        • Finding an element by its inner text
      • Summary
      • Chapter 3: Overview of Selenium WebDriver
        • Important preliminary points
        • History of Selenium
        • Architecture
          • WebDriver API
          • WebDriver SPI
          • JSON Wire protocol
          • Selenium server
          • The merging of two projects
        • How to set up your Java environment
        • Time for action – setting up Intellij IDEA project
        • Summary
        • Chapter 4: Design Patterns
          • Important preliminary points
          • Page Objects
          • Time for action – setting up the test
          • Time for action – moving Selenium steps into private methods to make tests maintainable
          • Time for action – using the Page Object Pattern to design tests
          • Using Page Factories with Page Objects
          • Time for action – using PageFactory
          • LoadableComponent
          • Time for action – changing our Page Object to use LoadableComponent
          • Summary
          • Chapter 5: Finding Elements
            • Important preliminary points
            • Finding elements
              • Finding an element on the page by its ID
            • Time for action – using findElementById()
              • Finding elements on the page by their ID
            • Time for action – using findElementsById()
              • Finding an element on the page by its name
            • Time for action – using findElementByName()
              • Finding elements on the page by their name
            • Time for action – using findElementsByName()
              • Finding an element on the page by their ClassName
            • Time for action – using findElementByClassName()
              • Finding elements on the page by their ClassName
            • Time for action – using findElementsByClassName()
              • Finding an element on the page by their XPath
            • Time for action – using findElementByXPath()
              • Finding elements on the page by their XPath
            • Time for action – using findElementsByXpath()
              • Finding an element on the page by its link text
            • Time for action – using findElementByLinkText()
              • Finding elements on the page by their link text
            • Time for action – using findElementsByLinkText()
            • Finding elements using a more generic method
            • Time for action – using findElement()
            • Time for action – using findElements()
            • Tips and tricks
              • Finding if an element exists without throwing an error
              • Waiting for elements to appear on the page
                • Implicit waits
            • Time for action – using implicit waits
              • Explicit waits
          • Time for action – using explicit waits with Selenium WebDriver
          • Summary
            • Chapter 6: Working with WebDriver
              • Important preliminary points
              • Working with FirefoxDriver
              • Time for action – loading the FirefoxDriver
                • Firefox profile preferences
              • Time for action – setting Firefox preferences
                • Installing a Firefox add-on
              • Time for action – installing the add-on
              • Working with ChromeDriver
              • Time for action – starting Google Chrome or Chromium
                • ChromeOptions
              • Time for action – using ChromeOptions
              • Working with OperaDriver
              • Time for action – starting Opera
                • OperaProfile
              • Time for action – working with OperaProfile
              • Working with InternetExplorerDriver
              • Time for action – working with Internet Explorer
              • Other important points
              • Summary
              • Chapter 7: Mobile Devices
                • Important preliminary points
                • Working with Android
                  • Emulator
                • Time for action – creating an emulator
                  • Installing the Selenium WebDriver Android Server
                • Time for action – installing the Android Server
                  • Creating a test for Android
                • Time for action – using the Android driver
                • Running with OperaDriver on a mobile device
                • Time for action – using OperaDriver on Opera Mobile
                • Working with iOS
                • Time for action – setting up the simulator
                • Time for action – setting up on a real device
                  • Creating a test for iOS devices
                • Time for action – using the iPhone driver
                • Summary
                • Chapter 8: Getting Started with Selenium Grid
                  • Understanding Selenium Grid
                  • Selenium Grid Hub
                  • Time for action – launching the hub
                  • Adding instances to the hub
                  • Time for action – adding a server with the defaults
                  • Adding Selenium Remote Controls for different machines
                  • Time for action – adding Selenium server for different machines
                  • Adding Selenium server to do specific browser tasks on specific operating systems
                  • Time for action – setting the environment when starting Selenium Remote Control
                  • Using Selenium Grid 2 with your YAML file
                  • Time for action – using Selenium Grid 1 configuration
                  • Running tests against the grid
                  • Time for action – writing tests against the grid
                  • Running tests in parallel
                  • Time for action – getting our tests running in parallel
                  • Summary
                  • Chapter 9: Advanced User Interactions
                    • Important preliminary points
                    • What is the Advanced User Interactions
                      • Keyboard
                      • Mouse
                    • Actions
                      • Drag and drop
                    • Time for action – creating an Actions chain for dragging and dropping
                      • Moving an element to an offset
                    • Time for action – moving an element with a drag-and-drop by offset
                      • Doing a context click
                    • Time for action – doing a context click
                      • Clicking on multiple items in a select element
                    • Time for action – selecting multiple items on a select item
                      • Holding the mouse button down while moving the mouse
                    • Time for action – holding the mouse button down while moving the mouse
                    • Summary
                    • Chapter 10: Working with HTML5
                      • Important preliminary points
                      • Working with application cache
                      • Time for action – getting the current status of application cache
                      • Interacting with browser connections
                        • Seeing if the browser is online
                      • Time for action – seeing if the browser is online
                        • Setting the browser offline or online
                      • Time for action – setting the browser connection to offline or online
                      • Working with WebStorage
                        • Local storage
                      • Time for action – accessing localStorage
                        • Session storage
                      • Time for action – accessing sessionStorage
                      • Summary
                      • Chapter 11: Advanced Topics
                        • Important preliminary points
                        • Capturing screenshots
                          • Capturing base64 version of images
                        • Time for action – capturing images as base64 strings
                          • Saving the screenshot to bytes
                        • Time for action – saving images to bytes
                          • Saving screenshots to files
                        • Time for action – saving a screenshot to file
                        • Using XVFB with Selenium
                        • Time for action – setting up XVFB server
                          • Running tests in XVFB
                        • Time for action – running tests with XVFB
                        • Working with BrowserMob Proxy
                          • Creating a proxy
                        • Time for action – starting the proxy
                          • Capturing network traffic
                        • Time for action – capturing network traffic
                        • Summary

                            David Burns

                            David Burns is a Senior Developer in Test having worked with Selenium for quite a few years. He is a Selenium Core Committer and so he knows and understands what users and developers want from the framework.

                            Sorry, we don't have any reviews for this title yet.

                            Submit Errata

                            Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                            Errata

                            - 19 submitted: last submission 22 Aug 2013

                            Errata type: Technical    Page No: 28
                            Time for action - working with AJAX applications
                            Steps:
                            1. Click on the load text to the page button.
                            2. Navigate to http://book.theautomatedtester.co.uk/chapter1.
                            Are reverse and should be:
                            1. Navigate to http://book.theautomatedtester.co.uk/chapter1.
                            2. Click on the load text to the page button.

                            Errata type: Code    Page No: 90
                            Step 2 code is incorrect:
                            Assert.equals(1, elements.size());
                            should be:
                            Assert.assertEquals(1, elements.size());

                            Errata type: Others || Errata date: 13-1-2012

                            The full form of DSL is Domain Specific Language

                             

                            Errata Type: Code | Page No: 83:

                            Chapter 4 under “Time for action – changing our Page Object to use LoadableComponent”, the code in step 4 is shown starting as follows:
                            @override
                            Protected void load() { ...
                            “@override” should be “@Override” (capitalized) and “Protected” should be “protected” (not capitalized).

                            Errata Type: Technical | Page No: 78:

                            In Chapter 4 under the section "Time for action - using PageFactory", step 1 reads as follows:"Open the previous example and go to Chapter2.java. It should look like the following example:"
                            It should be:
                            "Open the previous example and go to Chapter2.java. Update the code so it matches the following example:"

                            Errata Type: Code | Page No: 78:

                            Chapter 4 under section “Time for action - using PageFactory”, in the example code shown for Chapter2.java the code includes the following line:
                            verifybutton=selenium.findElement(By.id("verifybutton"));
                            It should be:
                            verifybutton=selenium.findElement(By.name("verifybutton"));

                            Errata Type: Technical | Page No: 91:
                            Chapter 5 under section "Finding an element on the page by its name", the second to last sentence in this section reads,
                            "The using variable takes the ID of the element that you wish to look for."
                            It should be:
                            "The using variable takes the name of the element that you wish to look for."

                            Errata Type: Technical | Page No: 93:
                            Chapter 5 under the section “Finding elements on the page by their name”, the second to last sentence reads:
                            The using variable takes the ID of the element that you wish to look for."
                            The findElementsByName method uses name, not id when searching for elements.
                            The sentence should read:
                            The using variable takes the name of the element that you wish to look for."

                            Errata Type: Code | Page No: 90:
                            Chapter 5 under the section “Time for action – using findElementsById()”, in step 2 the code includes the following:
                            List<WebElement> elements = ...
                            In order for List to work, the user must add the following to the class:
                            import java.util.List;
                            (the IntelliJ IDEA IDE provides a nice hint here)

                            Errata Type: Code | Page No: 84:
                            Chapter 4 under section “Time for action – changing our Page Object to use LoadableComponent”, in step 7 the code shown includes the following:
                            @protected
                            public void isLoaded() { ...
                            This should instead read:
                            protected void isLoaded() { ...

                            Errata Type: Code | Page No: 84:

                            Chapter 4, under the section Time for action - changing our Page Object to use a LoadableComponent, in step 7 the code displayed includes the following:
                            @override
                            Protected void load() {...
                            The code should read as follows to correct capitalization issues:
                            @Override
                            protected void load() { ...

                             

                            Errata type: Code | Page 76

                            The clickChapter method in the HomePage.java file should be a public method.

                             

                            Errata type: Code | Page 75
                            Assert.assertEquals(selenium.findElements(By.id("verifybutton")).size(), 1);
                            Should be:
                            Assert.assertEquals(selenium.findElements(By.name("verifybutton")).size(), 2);
                            This is because we have 2 buttons on the page Chapter2 with the name "verifybutton".

                            Errata type: Code | Page No: 97

                            The code in step 2 "We are going to use the command:"
                            WebElement element = ((FindsByXPath)driver).findElementByXPath("verifybutton");
                            Should be:
                            WebElement element = ((FindsByXPath)driver).findElementByXPath("//input[@id='verifybutton']");

                             

                            Errata type: Typo    Page No: 113
                            Time for action - setting Firefox preferences
                            Steps:
                            Step 4. has a line in the code as:
                            profile.setPreference("browser.startup.homepage", "http://book,theautomatedtester.co.uk/chapter4");
                            This should be:
                            profile.setPreference("browser.startup.homepage", "http://book.theautomatedtester.co.uk/chapter4");

                            Errata type: Technical    Page No: 17
                            Time for action – updating a test to verify items on the page
                            Steps:
                            Step 3. Select Selenium Grid from the drop-down box.
                            Step 4. Change the Select to Selenium Grid .
                            This should be:
                            Step 3. Select the radio button.
                            Step 4. Change the Selenium IDE drop-down to Selenium Grid.

                            Errata type: Code    Page No: 43
                            Adding filters to the name
                            An example of this on the page would be name=verifybutton value=chocolate;.
                            This should be:
                            An example of this on the page would be name=verifybutton1 value=chocolate;.

                            Errata type: Graphics    Page No: 24

                            The screenshot given in the Time for action – complex working with multiple windows section is wrong. There's no screenshot for this section.

                            Errata type: Support    Page No: 50

                            The URL https://github.com/KentBeck/junit/downloads should be https://github.com/junit-team/junit/releases

                            Sample chapters

                            You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                            Frequently bought together

                            Selenium 2 Testing Tools: Beginner’s Guide +    Web Services Testing with soapUI =
                            50% Off
                            the second eBook
                            Price for both: ₨351.00

                            Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                            What you will learn from this book

                            • Learn the basics of breaking down a web application for testing
                            • Understand AJAX calls and how they work with your tests
                            • Create basic scripts that allow you to recreate issues quickly
                            • Set up Firefox Driver, Firefox profiles, and extensions
                            • Get your tests working on mobile devices
                            • Migrate your tests from Selenium RC to Selenium WebDriver
                            • Handle tests quicker by running them in parallel and reduce build time

                            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.

                            Approach

                            This book is written in Beginner’s Guide style which emphasizes the concept of learning by doing. The book is packed with examples and code so that you can get the best out of this book.

                            Who this book is for

                            If you are a Software Quality Assurance professional, Software Project Manager, or a Software Developer interested in automated testing using Selenium, this book is for you. Web-based application developers will also benefit from this book.

                            Code Download and Errata
                            Packt Anytime, Anywhere
                            Register Books
                            Print Upgrades
                            eBook Downloads
                            Video Support
                            Contact Us
                            Awards Voting Nominations Previous Winners
                            Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                            Resources
                            Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software