Software Automated Testing
Keyword Data Driven Framework Selenium Robot
Best Practices
Agenda
² Automation Engineering Introduction ² Keyword Data Driven
² How to build a Test Automa7on Framework ² Selenium Introduction
² Robot Framework and Demo
² Test Automation Best Practices ² Q/A
Automation Engineering
§ What is Automated Testing
• use of special so,ware to control the test
execu3on and the comparison of actual outcomes to predicted outcomes.
• Test automa3on can automate some repe33ve
but necessary tasks in a formalized tes3ng process already in place, or add addi3onal tes3ng that
would be difficult to perform manually
Benefit of Test Automation
§ More reliable § Repeatable
§ Less time consuming § Less boring
§ Unattended Test Execution
§ Execute tests could not be done by human § Less expensive
GUI Test Automation
§ Test Scripts § GUI Objects
GUI object 1 Logical Name { Physical descriptions } ……… GUI object n:
TSL 1 (GUI Object, other parameters); ……….. TSL n (GUI Object, other parameters);
Controls/Objects
GUI Repositories AUT
Command Interactive Test
Automation
§ Test requires interactive steps § Via console, CLI
§ Use command language: TCL, Expect, Perl, Unix shell…
What should Automate?
§ Regression tests
§ Test for stable applications/features § Repetitive tests
§ Acceptance test (positive test) § Boundary & capacity tests
§ Sanity & spot tests
What should NOT automate
§ Usability testing
• "How easy is the applica7on to use?" § One-time testing
§ "ASAP" testing
• "We need to test NOW!"
§ Ad hoc/random testing
• based on intui7on and knowledge of applica7on § Tests without predictable results
Test Automation Process
§ Creating Tests
• Create tests using both recording and programming
• Insert checkpoints where is wanted to check the behavior of the applica7on being tested
§ Running Tests
• Emulate users to interact to AUT
• Compares the current response of AUT to its expected result
§ Analyzing Test Results
• Examine the test results
• Test results: major events that occurred during the run tests
Automated Testing Methodology
§ Record/Playback Method
• Tes7ng Tool records keystrokes, mouse ac7ons, verifica7on lists, etc. and playback then
§ Functional Decomposition Method
• The Applica7on is broken down into Business Func7ons
• Automated Scripts are developed using the Test Script to perform those func7ons
• Data-‐Driven Process using Input & Verifica7on Data Files
§ Test-Plan Driven Method
• The Test Cases are broken down into 'generic' tes7ng ac7ons
• Scripts are developed using the test scripts to perform these 'generic' ac7ons • Input File controls the processing as well as providing the Input and
Verifica7on data
Record/Playback
§ Advantages
• Easy to Use
• Tester just starts recording and executes the Manual Test Case
§ Disadvantages
• Reliability
• The tester can make errors, which are then recorded, and have to be corrected
• Failure on replay due to 7ming issues
• Failure on replay due to events that occur that were not recorded (pop-‐ups, messages, etc.)
• Maintenance
• Scripts contain hard-‐coded data that must be updated if the Applica7on or the Data changes
• Scripts must be enhanced or corrected aYer recording
• Scripts & verifica7on need to be re-‐recorded if the Applica7on processing changes
Functional Decomposition
§ Maintenance
• Modular design: If a Business Func7on changes, only a few scripts must be modified
• Complex Test Cases can be constructed by calling Business Func7on Scripts from a Main Rou7ne
• Data-‐Driven: Script can be used for many Test Cases by using different input/verifica7on files
§ Reliability
• Tester error is eliminated, as is "scripter error" aYer the script has been properly coded and tested
• Unexpected events (pop-‐ups, messages, etc.) can be an7cipated and coded for
Functional Decomposition
§ Maintenance
• Each Business Func7on requires a script. There may be hundreds of Business Func7ons
• Changes in Test Cases require updates to several sets of input/verifica7on files for each Test Case • Format of input/verifica7on records must be
strictly adhered to or the tests will fail
• Testers must maintain the input/verifica7on records as well as the Test Case documenta7on
Keyword Data Driven
§ A proven methodology which applied SUCCESSFULLY in Software Automated Testing
§ Action-based Testing
§ Test scripts vs test cases
§ Automation Test Engineer vs Developer in Test
How To Build
Driver
Controller
Test Modules/Test cases Test Plan/Test Modules
Read Read . . . Libraries/Functions Call Reports Return Call Write “KEYWORDS”
Test Modules/Test cases Test Modules/Test cases
Test Modules/Test cases
Test Cases
Selenium Introduction
§ Selenium is a Functional Automation tool for Web applications.
§ Selenium is an open source tool (No cost Involved in it). § Selenium supports the languages like HTML, Java, PHP,
Perl, Python, Ruby and C#.
§ It supports the browsers like IE, Mozilla Firefox, Safari, Google Chrome and Opera.
§ It supports the operating systems like Windows, Linux and Mac.
§ It is very flexible when compared to QTP and other
Components
§ Selenium IDE
§ Selenium RC(Remote Control) § Selenium Grid
SELENIUM IDE
§ IDE stands for Integrated Development Environment. § Which is used for Record and Play back the scripts.
§ It is an Add on for Mozilla Firefox, which means we can download the Selenium IDE from Mozilla Firefox and we can Record and Run the scripts in Mozilla Firefox only. § Selenium IDE is accountable for user actions.
§ We can Run the Recorded scripts against other browsers by using Selenium RC
Selenium RC
§ It is a Server and launches the Browser.
§ It acts as a API and Library of Selenium.
§ We need to configure the Selenium RC with the supported language, then we can
Selenium Grid
§ Selenium Grid is used for launching the multiple browsers with supported operating system in
parallel.
§ We can run the scripts on different browsers in parallel.
§ It allows you to easily run multiple tests in parallel, on multiple machines, in a
Scripting(Selenese)
§ Selenium commands, often called selenese. The set of these commands are nothing but test script.
§ If you want to write test scripts for any application, initially you need to integrate Selenium with Java by using
Eclipse. (check the Integration doc).
§ After completion of the integration, First we need to create the selenium object as below.
§ DefaultSelenium selenium=new
DefaultSelenium(“System address”, ”Port no of selenium”, “Browser to launch”, “url”).
Basic Selenese
§ Start(): To launch the Browser. § Open(): To open the url.
§ Close(): To kill or close the Browser.
§ windowMaximize(): To maximize the window. § Type(): To enter some text into a text box.
§ Click(): To click on Button, Radio button and Link.
§ Select(): To select a value or label from combo box or list box or Drop down.
§ Check(): To check the check box.
§ selectPopUp(): To identify the pop up window. § selectWindow(): To identify the child window. § selectFrame(): To identify the frame.
§ getAlert(): To Click ok on alert box.
§ getConfirmation(): To click ok on confirmation message.
§ chooseCancelOnNextConfirmation(): To click Cancel on next displayed confirmation message.
§ chooseOkOnNextConfirmation(): To click Cancel on next displayed confirmation message.
Selenium Driver Script Environment Test Cases Test Results Test Data AUT
Selenium Framework
What It is
§ Python-based, keyword data-driven test automation framework for end-to-end acceptance testing
§ Open source
Features
§ Enables easy-to-use tabular syntax for creating test cases in a uniform way. § Allows using keyword-driven, data-driven and behavior-driven (BDD) approaches. § Provides ability to create reusable higher-level keywords from the existing keywords. § Provides easy-to-read reports and logs in HTML format.
§ Is platform and application independent.
§ The modular architecture supports creating tests even for applications with several diverse interfaces.
§ Provides a simple library API for creating customized test libraries.
§ Provides a command line interface and XML based outputs for integration into existing build infrastructure (continuous integration systems).
§ Provides support for Selenium for web testing, Java GUI testing, running processes, Telnet, SSH, and so on.
§ Remote library interface enables distributed testing and implementing test libraries in any programming language.
§ Provides tagging to categorize and select test cases to be executed.
Integration
§ Editor: RIDE
§ Selenium Library – Web testing § Jenkins Plug-in
§ Sikuli application – app testing § Extended Python/Java Libraries
Keywords
§ BuiltIn keywords § Library keywords
• All lowest level keywords are defined in test libraries which are implemented using standard programming languages.
• Opera3ngSystem Lib: to support common opera3ng system func3ons
• SeleniumLibrary : Web tes3ng
• Screenshot library: taking screenshots
§ User-defined keywords
• WHEN: no suitable library available
• Create new higher-‐level keywords from other keywords
Demo
h^p://robo_ramework.org/
§ Eliminate “Record/Playback hard-coding” § Apply coding guidelines
§ Exception handling § Batch Test
§ Re-usable & portable § Customized reporting § Memory leaks
§ Dynamic GUI load § Wise loop
§ Remote Controlling Test Execution § Progress Testing Status