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 Wikipedia
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 Application Under Test (AUT)
GUI Repositories AUT Controls/Objects GUI object 1 Logical Name { Physical descriptions } GUI object n: TEST SCRIPT TSL 1 (GUI Object, other parameters);.. TSL n (GUI Object, other parameters);
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 Load performance or stress test
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 Commonly Used Methodologies 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 Advantages 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 Disadvantages 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 Read Test Plan/Test Modules Write Call Return Controller Read Test Modules/Test cases Test Modules/Test cases Test Modules/Test cases Reports Call KEYWORDS Libraries/Functions Test Modules/Test cases... GUI Repository
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 functional tools, because it supports multiple languages.
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 automate the application.
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 heterogeneous environment.
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 Framework Environment Selenium Driver Script Test Results Test Data Test Cases AUT
ROBOT FRAMEWORK
What It is Python-based, keyword data-driven test automation framework for end-to-end acceptance testing Open source https://code.google.com/p/robotframework/
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. Has built-in support for variables, practical particularly for testing in different environments.
Integration Editor: RIDE Selenium Library Web testing Jenkins Plug-in Sikuli application app testing Extended Python/Java Libraries
Architecture
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 Powerful feature of Robot F.
How it works
Demo h^ps://code.google.com/p/robo_ramework/ h^p://robo_ramework.org/
BEST PRACTICES
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