Header Ads

How To Create Parameterization in QTP

Image credit http://www.gizmodo.com.au
When record a Test step, it is more about static in nature as the data are hard coded in the script.Parametrization is the very next step while making test dynamic in nature.Now let us understand what is parameter? A parameter is a variable that is assigned a value from different source or generator. You can say a variable to store temp data.
Through Passing parameters, we can pass multiple values.We use parameterization in Data Driven Testing.

Which phase we can provide data to Script
How to get data from different source:

  • Through Loop Statements
  • Dynamic Test Data Submission,user input during execution
  • Through Data Table
  • Fetching Test Data directly from External files (Flat files & Spreadsheets)
  • Fetching Test Data directly from Databases (MS Acess, oracle etc).
  • Getting Test Data from front end objects.
Phases of test where you can give some data



Parametrization Through Loop Statements:

We can use loop statements for passing sequential numbers & Logical Numbers.
For order_no=1 to 10 step 1 ' for one increment step keyword is not mandatory
Window("Flight Reservation").Activate
//activate the Flight reservation window
Window("Flight Reservation").WinButton("Button").Click
//Click on the reservation button
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
//Setting the order check box as true
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set order_no
//Providing looping value
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Next
Even we can create several other users like Users_1 to user_n,Order_1 to order_n,Item_1 to Item_n etc

Through Data Table:
QTP adds one data table (Spreadsheet) for every test, we can use Data Table for Data Driven Testing.
It has 3 types of usage


  • Entering test data directly into data table and use
  • Importing test data from external Flat files(.txt,.csv)
  • Importing test data from external Spread sheets(.xls)
  • Importing test data from Data bases.(Oracle,MySQL)

Dynamic User input:
This is such type data which is bit dynamic but needs manual intervention for making it dynamic.
Please visit here for more details:

Via Datatable:
We will use the datatable syntax for getting values:

variable xyz=datatable("column name", Sheet id)

Let's see how it works:
Agent = Datatable("Agent",1)
pwd=Datatable ("Password",1)
invokeapplication "E:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Agent
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure pwd
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
if you are using action based framework , the method can be called but data will come from action datatable.
Powered by Blogger.