Selenium 2 Testing Tools: Beginner’s Guide

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.

Selenium 2 Testing Tools: Beginner’s Guide

Beginner's Guide
David Burns

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.
$10.00
$44.99
RRP $26.99
RRP $44.99
eBook
Print + eBook
$12.99 p/month

Get Access

Get Unlimited Access to every Packt eBook and Video course

Enjoy full and instant access to over 3000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Code Files
+ Collection
Free Sample

Book Details

ISBN 139781849518307
Paperback232 pages

About This Book

  • 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

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.

Table of Contents

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
Time for action – finding elements by direct XPath
Using XPath Axis to find elements
Time For Action – using XPath Axis
CSS selectors
Time for action - finding elements by CSS
Time for action – finding the nth element with CSS
Summary
Chapter 3: Overview of Selenium WebDriver
Important preliminary points
History of Selenium
Architecture
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
Time for action – using findElementById()
Time for action – using findElementsById()
Time for action – using findElementByName()
Time for action – using findElementsByName()
Time for action – using findElementByClassName()
Time for action – using findElementsByClassName()
Time for action – using findElementByXPath()
Time for action – using findElementsByXpath()
Time for action – using findElementByLinkText()
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
Time for action – using implicit 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
Time for action – setting Firefox preferences
Time for action – installing the add-on
Working with ChromeDriver
Time for action – starting Google Chrome or Chromium
Time for action – using ChromeOptions
Working with OperaDriver
Time for action – starting Opera
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
Time for action – creating an emulator
Time for action – installing the Android Server
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
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
Actions
Time for action – creating an Actions chain for dragging and dropping
Time for action – moving an element with a drag-and-drop by offset
Time for action – doing a context click
Time for action – selecting multiple items on a select item
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
Time for action – seeing if the browser is online
Time for action – setting the browser connection to offline or online
Working with WebStorage
Time for action – accessing localStorage
Time for action – accessing sessionStorage
Summary
Chapter 11: Advanced Topics
Important preliminary points
Capturing screenshots
Time for action – capturing images as base64 strings
Time for action – saving images to bytes
Time for action – saving a screenshot to file
Using XVFB with Selenium
Time for action – setting up XVFB server
Time for action – running tests with XVFB
Working with BrowserMob Proxy
Time for action – starting the proxy
Time for action – capturing network traffic
Summary

What You Will Learn

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

Authors

Table of Contents

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
Time for action – finding elements by direct XPath
Using XPath Axis to find elements
Time For Action – using XPath Axis
CSS selectors
Time for action - finding elements by CSS
Time for action – finding the nth element with CSS
Summary
Chapter 3: Overview of Selenium WebDriver
Important preliminary points
History of Selenium
Architecture
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
Time for action – using findElementById()
Time for action – using findElementsById()
Time for action – using findElementByName()
Time for action – using findElementsByName()
Time for action – using findElementByClassName()
Time for action – using findElementsByClassName()
Time for action – using findElementByXPath()
Time for action – using findElementsByXpath()
Time for action – using findElementByLinkText()
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
Time for action – using implicit 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
Time for action – setting Firefox preferences
Time for action – installing the add-on
Working with ChromeDriver
Time for action – starting Google Chrome or Chromium
Time for action – using ChromeOptions
Working with OperaDriver
Time for action – starting Opera
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
Time for action – creating an emulator
Time for action – installing the Android Server
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
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
Actions
Time for action – creating an Actions chain for dragging and dropping
Time for action – moving an element with a drag-and-drop by offset
Time for action – doing a context click
Time for action – selecting multiple items on a select item
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
Time for action – seeing if the browser is online
Time for action – setting the browser connection to offline or online
Working with WebStorage
Time for action – accessing localStorage
Time for action – accessing sessionStorage
Summary
Chapter 11: Advanced Topics
Important preliminary points
Capturing screenshots
Time for action – capturing images as base64 strings
Time for action – saving images to bytes
Time for action – saving a screenshot to file
Using XVFB with Selenium
Time for action – setting up XVFB server
Time for action – running tests with XVFB
Working with BrowserMob Proxy
Time for action – starting the proxy
Time for action – capturing network traffic
Summary

Book Details

ISBN 139781849518307
Paperback232 pages
Read More