Parameterization is nothing but giving multiple
Input/Test data to the test script.
1. Input the
Test data from External files.
2. Input the
Test data through Datatable.
3. Input Test
data through loop statements.
4. Input Test
data dynamically through interactive submission.
Parameterization is a process in which parameters,
or variables are substituted for hard-coded values which help perform the same
operations on the AUT with multiple sets of data. In other words, in QTP,
parameterization helps automation developers test an application with different
data from a single action (or multiple actions) through multiple iterations.
Because the data changes each iteration, it must be stored in a data-pool, or
in multiple variables. This data-pool can be QTP’s (Local or Global)
DataTables, an Excel Spreadsheet (external to QTP), Access DB, SQL Server, or
any database of your choice. It can also come from several Environment
variables.
Before we start with the actual parameterization, we
must first understand how data will be retrieved from the DataTable and the
settings that we need to make in order to cover all the rows. In our example,
we will test a few UserName and Passwords in the HP/Mercury’s Demo AUT.
Below, I have created 2 columns in the Local
(Action1) DataTable- UserName & Password. You can create columns by simply
double-clicking the Column heading:
Next, I will create 4
rows with different sets of data:
Below is the syntax to retrieve data from the
DataTable’s local sheet:
'If retrieving data from Local DataTable (Action1,
Action2,.. ActionN)
DataTable("ColumnName", dtLocalSheet)
'If retrieving data from Global DataTable
(dtGlobalSheet)
DataTable("ColumnName", dtGlobalSheet)
Therefore, we can now create 2 statements using the
syntax above to retrieve our user name and password:
DataTable("UserName", dtLocalSheet)
DataTable("Password", dtLocalSheet)
Before we create our script, we must first tell QTP
to run the test from all rows in the Local DataTable. In Keyword view,
right-click Action1 then click Action Call Properties:
In the Run Tab of Action Call Properties window,
select “Run on all rows”. A Dialog will popup mentioning what we discussed in
the beginning of this post, about ending our iteration where the first step in
our process begins.
Close the dialog, then
click OK to save the settings we made under Action Call Properties. We are now
ready to create our script which will take data from each row and test each UserName/Password
combination. Below will be the steps in our process:
Steps:
- generate the basic
test> open data table(view>data table)
- click on column
header>enter the name of the field(like we can create number of
coloumns).enter data >connect the data to test.
(variable=datatable(“column
name” sheet id)
-run the test
Example :
Invoke application ("c:\Program Files\IE.exe.exe”)
Dialog(“login”).Active
Dialog(“login”).winedit(“agent
name”).set agent
Dialog(“login”).winedit(“password”).setsecure
pwd
Dialog(“login”).winbutton(“ok”).click
Window(“flightreservation”).close
Open data
table(open>data table) > right click >file > import from file
>click ok >browser path of the file(it imports data from the flat file)
Open data
table(open>data table) > right click >file > import from file
>click ok >browser path of the excel sheet(it imports data from the excel
sheet)
No comments:
Post a Comment