Selenium is a suite of tools to automate web application testing across many platforms .
What is Selenium
Framework for automation testing tool for web applications
IDE for record / playback -> creation of tests -> learning language
DSL for writing test scripts in Java, Ruby and others
Support for all major browsers
Selenium Remote Control
Selenium – General Overview
Steps: Selenium IDE: Record and playback Selenium IDE: Export as Java code Selenium RC: Execute Java(Eclipse-Junit) Selenium GRID: distribute on various environments demo: Selenium IDE: record, replay and export Selenium – General Overview
Selenium commands (Selenese) A set of commands that run the tests for a web-based application:
check if the correct UI elements exist;
check the specific content of the UI elements;
check that all links are functional;
check data entry field (input of data and check of the values);
checks the option selection on different UI elements (radio buttons, check boxes, drop down lists);
checks the form submit options;
check for applications using Ajax calls.
There are 3 Types of commands:
Actions - commands that manage the state of the application
“ click link”, “select option”, Fail = the execution of the test case stops/ends, ...AndWait – a post-back is set and Selenium waits until the execution is completed
Accessors – check the state of the variables that are used in Assert commands
Assertions – check that the state of the aplication is exactly what and how is expected. E.g.. “the title of the page is ”abc” or that “checkbox is selected”. There are 3 methods to check:
“ assert” (the test stops),
“ verify”(error is logged and the test continues )
” waitFor” (awaits until a restriction is aquired – used for testing applications with AJAX).
Selenium – General Overview
Client library : Transforms the Java calls into server commands, by encoding it into the “Selenese” network protocol (on top of HTTP) and sending it to the Selenium server.
E.g. “start browser”, “click-to”...
Server component : Listens for commands from clients (on a TCP socket) and performs actions accordingly.
E.g. starting web-browser or forwarding “user interaction” to the web-browser and delivering back the result to the client. Selenium – General Overview
S peeds up functional testing of web-applications by leveraging the existing computing infrastructure;
Allows easily running multiple tests in parallel, on multiple machines, in an heterogeneous environment;
Allows running multiple instances of Selenium Remote Control in parallel. Even better, it makes all these Selenium Remote Controls appear as a single one, so the tests do not have to worry about the actual infrastructure;
Selenium Grid cuts down on the time required to run a Selenium test suite to a fraction of the time that a single instance of Selenium instance would take to run.
Selenium – General Overview
Open source tool for web application (no license costs, large community for support and continuous development);
support for multi platform and multi browser in terms of coverage;
DOM testing – simple and strong;
The TC are stable, for mature versions;
Supports testing AJAX applications;
Allows building flexible testing scenarios within the power of Java.
Error diagnoze and reporting;
Upon UI changes, the scripts need update (general for all automation tools);
It is state dependent (html driven);
May require more knowledge (learning effort may be high in the beginning).
Future and actual Selenium projects:
Selenium 2.0 (Selenium + WebDriver)
Drivers: HtmlUnit / Firefox / IE / Chrome
Selenium Logging – utility for RC for creating reports in html format, including time measurement and automatic screenshots (http://loggingselenium.sourceforge.net/usage.html).
Selenium – review
Starting point: Test Plan
Functionality tree and initial evaluation of total effort (main functionalities and test cases)
Manual versus Automation testing
Decision for the solution of automation testing
GUI and usability
Regressions and others
Main risks to evaluate for automation:
No automation - The quality of the testing and the time invested
The cost of development and maintenance of the automated tests
Result: We implement the automation testing in a structured layered architecture using Selenium Selenium – review
Test Project Structure Working together with Development and QA to implement the test framework structure.
separate test-framework code from the actual tests classes
separating reusable, generic test-framework code from a project specific code
Tempo Project Tempo – a story about time
Purpose of the application
Possible user scenarios – as acceptance tests
Structure considered for testing
Demo of the Tempo project
Identifying the page and panes objects for testing structure – Time Tracking page Tempo Project Time Tracking Page Time Tracking Pane Time List Pane Tag Pane Live View Pane
Diagram of tempo test project This is where QA designs the tests.
complex functionalities covering the usage of the application;
specific user scenario or a combination of possible user actions;
validation data in one or more test classes;
data driven testing, when needed.
DEV and partly QA
Pages - Java class for each page under test with the UI elements to be verified and all methods that are used further in the tests;
Panes – Java classes for each panes identified in the pages and the verifying methods for each action;
Common - generic functionality executed in more pages or all pages e.g. navigation between all pages, cleaning/ preparing the database for tests, auto login executed before testing any page, others.
Elements: classes for basic HTML elements such as text field, check box, radio button, etc that encourage OO test code);
Browser Driver: browser driver utility (class) that builds an abstraction layer for selenium RC for controlling the browser (e.g. start, stop) and for implementing user actions methods (e.g. click, type text);
Extending the element location strategy by Injecting the entire jQuery framework into pages under test, in order to verify visibility of elements that appear after dynamic HTML or Ajax calls.
Use case: Open Time Tracking page and register the time in TEMPO application (time punch, time stamps, interval, duration). Check the results on the page.
instantiate page object TimeTrackingPage and within it we:
instantiate TimeTrackingPane – create new time stamp
instantiate TimeListPane – test that a new time stamp is listed
Instantiate TagPane – test that the new tag is loaded and displayed
Instantiate LiveViewPane – test the duration totals
Demo of the automation tests – explanation of the test class. Tempo Project