Automation Framework Guidelines

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

QTP Framework

Test Automation Framework Types of Framework Folder Structure Record & Playback or Linear Framework Modular Driven framework Data Driven Framework Keyword Driven framework Hybrid driven Framework Driver Script Creation Initialization Script --------------------------------------------------------------------------------------------------------------------------------------A) Process Guidelines: ----------------------i) Document Test Scenarios ii) Collect Test Data iii) Create Folder Structure to store Automation Resources like Object Repositories, Function Libraries, Environment Variable files, Recovery Scenarios Etc... iv) Create and Store Automation Resources

Automation Framework Guidelines

v) Build Tests using Automation Resources vi) Create Organizer Spread sheet to organize & Control Test execution Process (Usning Organizer Spread sheet, we can restric the Test execution Module wise and Test wise Organizer Provides instructions to Driver Script We can modify the Organizer based on our requirements) vii) Return Test results into Variables and export to external files viii) Create Driver script to run Tests one by one and export Results ix) Create Initialization script (AOM script File) (Initialization script launches QTP tool, Calls the Driver script. Driver script calls and execute tests one by one & export Results at end Initialization script quits the QTP Tool) x) Modifying the Organizer, Driver script and Other resources (If required) ------------------------------------------------------------B) Object Identification Guidelines: ------------------------------------C) Test Data Collection Guidelines ----------------------------------D) Tool Settings Configuration Guidelines: -------------------------------------------E) Test Scenarios Selection Guidelines: ---------------------------------------F) Trouble Shooting Guidelines ------------------------------G) Guidelines for Defining Test Results ------------------------------------------

QTP Framework

Automation Framework

Automation: Accessing one Software Objects from another Software is called Automation. (AUT is one s/w and Testing Tool is another s/w.) Automation Framework: It is a set of guidelines, assumptions and process developed by experts in order to perform a task(s) in an effective, efficient and optimized way. A systematic approach for automating software applications. Why Automation Framework: In one project test automation we use various files, we perform various tasks, in order to organize and manage them all, a systematic approach (Automation Framework) required. files to be used: a) Flat files (.txt), b) Excel files (.xls) c) Object repository files (.tsr) d) XML files (.xml) e) Library files (.vbs) f) Test Scripts (.mts) g) Test Batch Files (.mtb) h) Recovery scenario files (.qrs) i) Test Result file (.XML) Tasks to be performed: a) Analyzing the application We analyze the AUT in terms of Object Identification and Functionality. Basically, QTP is an Object based test tool, here first we have to confirm Etc...

if the QTP is recognizing all the objects in our application or not. To do this, we can follow one or more below given methods... i) Record and playback some End to End Scenarios. ii) Using Object Spy iii) Using Object Repository Manager We can segregate Software Objects in 3 categories... i) Static Objects(Properties information is constant) ii) Dynamic Objects(Properties info changes dynamically) iii) Duplicate Objects(Having Similar property info.) Note:We can handle dynamic Objects using Regular expressions and handle duplicate Objects using "Index" property. b) Selecting Areas/Test Cases for Automation Overview: 100% test automation is not possible, we can go for maximum automation. i)Tests that we want to execute on multiple versions of software(Sanity,Regression Tests) ii)Tests that we want to execute with multiple sets of test data.(Data Driven Tests) iii) Tests having complex functionality c) Planning (Effort estimation,Schedule,Work allocation and Automation Framework implementation) Overview: After selecting some areas for Automation, we have to estimate the efforts in terms of time and resources(Environmental and Human) To estimate efforts, we can follow an one of the below given methods: a) Using Expert based techniques. b)Experienced based techniques. c)Function point analysis. 1) Identifying End to End Scenarios. 2) Identifying verification points. 3) Identifying General and Alternate Flows.

4) Identifying the modularity. 5) Identifying the complex functionality. d) Creating Generic and project specific functions. e) Creating required Automation resources(Functions,Object repository Files,Environment variable files---etc) f) Creating Tests(Using Object Repository or Descriptive Programming) g) Enhancing Tests(Inserting Checkpoints,Output Values,Transaction points,Flow Control Statements,Synchronization,Parametrization---etc ) h) Debugging and running tests(Individual test execution,Test Batch execution --etc) i) Defining and exporting test results j) Analyzing results k) Test reporting l) Defect Reporting using companies defect management system. m) Modifying tests n) Performing re and regression testing ---etc Types Of Automation Framework: Automation Framework is not a qtp feature, its a 3rd party concept. And this is purely local concept.(framework may vary from one company to another) 1. Record/Playback or Linear Framework (1st generation framework). In this Framework we create tests using recording,low resources maintenance, Form batches and executing tests. Drawbacks: Modifications and maintenance are difficult,less command on scripts,low performance ---etc 2. Modular Framework.

In this Framework,reusable components can be recognized,first we concentrate on creating reusable components, then creating tests using those components. Advantages: It reduces test Automation time Performance is high than recording and playback Drawbacks: Less usage of keywords,no concentration on Data driven testing and low performance than latest Frameworks like Keyword Driven Framework. 3. Data Driven Framework In this Framework,we concentrate more on Data Driven testing.We recognize positive and negative scenarios,then collecting test data and parameterizing. Advantages: We can check reliability of the system,positive and negative testing. Drawbacks: Less concentration on complex Functionality Testing and low keywords usage. 4. Keyword Driven framework 5. Hybrid Framework In the above frameworks Keyword Driven framework is very famous in the industry. It is a mixing of more than one approach. In this approach,we mix Data driven and Modular approaches OR Data Driven and Keyword Driven approaches---etc Advantages: Scope is very high as we mix different approaches,Flexible for performing any tasks.

Drawbacks: Organizing and managing resources are difficult,complex architecture,low in performance. NOTE: Now a days Mix of Data driven and Keyword driven approaches is a famous Hybrid Framework in the industry. Keyword Driven Framework Keyword: 1. Any word used as the key to a code 2 A reserved word used to identify a specific command, function etc. (in our test automation example keywords are : Keywords to be used in Test Automation: a) Test Objects (EX: Browser,page,webEdit,WinButton---etc) b) Functions (Built-In and User defined) c) Methods (Ex:Set,Select,Activate,Navigate---etc) d) Statements (EX:Dim,If,For---etc) e) Operators (EX: +,/,*,and,or,not---etc) Keyword Driven Approach: In this approach we use keywords for preparing tests. First we create tests and make them as functions, through framework we execute them and generate results. Key elements of Automation Framework: 1. 2. 3. 4. 5. Well defined folder structure Initialization script Driver script input data spreadsheet process guidelines document

Why folder structure? In order to create, store, organize and manage files a well defined folder structure required. Folder structure is a mandatory element of any framework, but folder names may vary from one framework to another and company to another . Folder Structure: 1. Object Repository 2. Environment 3. Library a) Company b) Project Specific 4. Test data 5. Test log 6. Recovery scenarios 7. Miscellaneous And 1. Initialization script (.vbs file) 2. Driver script (QTP Script file) 1) Object Repository: In this folder we store object repository files(.tsr), all team members can use this repositories. 2) Environment: In this folder we store environment variables files(.xml), all team members can use this variables. 3) Function Library:this folder contains two sub folders one is for storing common functions of our company, another folder for storing our project specific functions(.vbs). 4) Test Data: in this folder we store test data required for data driven testing, for that we use either .xls files or .txt files or .mdb files.

5) Test Log: In this folder we store test result(excel sheet). 6) Recovery scenarios: In this folder we store qtp recovery scenarios files(.qrs). 7) Miscellaneous: in this folder we store the files other than above files(exprocess guideline doc and messages among team members and instructions by team lead etc). And 1) Initialization script (.vbs file): It launches qtp tool and calls driver script, at end it closes qtp tool. 2) Driver script (QTP Script file): It is only the qtp script, we can associate all resources to this script

Driver Script
Generally in Keyword Driven Framework Driver Script is the only QTP Script, remaining all are Vb Script files (.vbs) Driver script organizes Tests execution and stores Test logs in the specified file/folder

Sample Driver Script


'adding sheets to runtime data table datatable.AddSheet ("Module") datatable.AddSheet ("Testcase") datatable.AddSheet ("Teststep") 'Importing sheets from an external excel file datatable.ImportSheet "C:\Documents and Settings\gcreddy\Desktop\flights\test data\inputdata.xls",1,"Module" datatable.ImportSheet "C:\Documents and Settings\gcreddy\Desktop\flights\test data\inputdata.xls",2,"Testcase" datatable.ImportSheet "C:\Documents and Settings\gcreddy\Desktop\flights\test data\inputdata.xls",3,"Teststep" Mrowcount=datatable.GetSheet("Module").getrowcount For i=1 to Mrowcount step 1 datatable.SetCurrentRow(i) Mexe=datatable.Value(3,"Module")

If ucase(Mexe)="Y" Then ModuleId= datatable.Value (1,"Module") Tcrowcount=datatable.GetSheet ("Testcase").getrowcount For j=1 to Tcrowcount step 1 datatable.SetCurrentRow (j) ModuleId1=datatable.Value(4,"Testcase") Tcexe=datatable.Value(3,"Testcase") If ModuleId=ModuleId1 and Ucase(Tcexe)="Y" Then TcId=datatable.Value(1,"Testcase") Tsrowcount=datatable.GetSheet("Teststep").getrowcount For k= 1 to Tsrowcount step 1 datatable.SetCurrentRow(k) Tcid1=Datatable.Value(5,"Teststep") If TcId= TcId1 Then keyword= datatable.Value(3,"Teststep") Select Case keyword Case "ln" res=Login() datatable.Value(6,"Teststep")=res Case "ca" close_app Case "op" res=Openord() datatable.Value(6,"Teststep")=res End Select End If Next End If Next End If Next datatable.ExportSheet "C:\Documents and Settings\gcreddy\Desktop\flights\testlog\results.xls","Teststep"

Sample Initialization Script


Initialization Script Launches QTP Tool and Calls Driver Script, Driver Script execute Tests and Stores Results. Finally Initialization Script Closes QTP tool Option Explicit

Dim qtApp set qtApp=createobject("QuickTest.Application") qtApp.Launch qtApp.Visible=True qtApp.Open "C:\Flight\Testscripts\Driver" qtApp.Test.Run qtApp.Quit

You might also like