UFT Parameterization

UFT Parameterization

What is Parameterization?
Replacing constant (fixed) values with parameters is called Parameterization.
-----------------------------------------
Purpose of Parameterization
    To pass multiple values
    To pass single value
----------------------------------------------
What is Data driven Testing?
Testing the same functionality using multiple sets of test data.
----------------------------------------------------
Why Data Driven Testing?
    For Positive and Negative Testing
--------------------------------------------------
Relation between Parameterization and Data driven testing

We use Parameterization feature in Data driven Testing.
------------------------------------------
How to Parameterize?
We can use either variables or Constants or Arguments or Action Parameters or Data Table parameters or Environment variables or Dictionary object keys as parameters.
---------------------------------------
Ways of Parameterization
i) Generate and pass values using Loop statements

ii) Dynamic Test data submission

iii) Using Data Table
    a) Enter Test data directly into data table and connect to the Test.
    b) Import Test data from external files (Text or Excel) into data table and connect to the Test.
    c) Import Test data from a Database into data table and connect to the Test.

iv) Using Action Parameters

v) Using Function Arguments

vi) Using Environment Variables

vii) Using Dictionary object

viii) Using Automation Objects
    a) Read test data directly from a text file and connect
    b) Read test data directly from an Excel file and connect
    c) Read test data directly from a Database and connect
--------------------------------------------------------------------
i) Generate and pass values using Loop statements
Using Loop statements we can generate some types of data

a) We can generate Sequential numbers (ex: 1, 2, 3..../23, 24, 25...)

b) We can generate Logical numbers (ex: 2, 4, 6.../1, 3, 5.../10, 20, 30....)
---------------------
a) We can't generate desired numbers (ex: 1, 7, 23, 45.....)

b) We can't generate String type data (ex: User name, Customer name, Password etc....)
---------------------------------------------
'Open 1 to 5 orders
For OrderNumber = 1 To 5 Step 1
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNumber
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Next
------------------------------------------
'Open even orders up to 10
For OrderNumber = 2 To 10 Step 2
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNumber
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Next
--------------------------------------------
'Open first 5 orders in reverse order
For OrderNumber = 5 To 1 Step -1
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNumber
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Next
-------------------------------------------
'Open first 5 orders except 4th order
For OrderNumber = 1 To 5 Step 1
If Not OrderNumber = 4 Then
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNumber
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
End If
Next
--------------------------------------------------------
'Open first 10 orders except 4th and 7th orders
For OrderNumber = 1 To 10 Step 1
If OrderNumber <> 4 And OrderNumber <> 7 Then
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNumber
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
End If
Next
------------------------------------------------------------
ii) Dynamic Test data submission
using this feature Tester can provide all types of Data.

But it is not recommendable for large amount of test data.
---------------------------------------------
For i = 1 To 3 Step 1
Agent = InputBox("Enter Agent Name")
Password = InputBox("Enter Password")
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\flight\app\flight4a.exe","","C:\Program Files\HP\Unified Functional Testing\samples\flight\app\",""
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Agent
Dialog("Login").WinEdit("Password:").Set Password
wait 2
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
Next
-------------------------------------------`
For captcha fields it is useful feature.
---------------------------------------------------
iii) Using Data Table    

a) Enter Test data directly into data table and connect to the Test.
    b) Import Test data from external files (Text or Excel) into data table and connect to the Test.
    c) Import Test data from a Database into data table and connect to the Test.
-----------
Steps for Data Driven Testing using Data Table
------------------------------
a) Generate the basic Test and run it once.

b) Launch Data Table and Enter / Import Test data

c) Connect Test data with the Test.
    (Using Editor View or Using Keyword view or using Data driver)

d) Run the Test
------------------------------------------------
Syntax:

DataTable(Column name / Column ID, Sheet name or Sheet Id)

Example:
--------------
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\flight\app\flight4a.exe","","C:\Program Files\HP\Unified Functional Testing\samples\flight\app\",""
Dialog("Login").WinEdit("Agent Name:").Set DataTable(1, 1)
Dialog("Login").WinEdit("Password:").Set DataTable(2, 1)
wait 2
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
-------------------------------------------------
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\flight\app\flight4a.exe","","C:\Program Files\HP\Unified Functional Testing\samples\flight\app\",""
Dialog("Login").WinEdit("Agent Name:").Set DataTable("Agent", dtGlobalSheet)
Dialog("Login").WinEdit("Password:").Set DataTable("Password", dtGlobalSheet)
wait 2
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
-----------------------------------------------------
We can use Text files or Excel files as Resource files.

If we use Text file as Resource then two syntax rules:

i) Data Table considers Text file first line as Field headers

ii) Tab space is the delimiter in between two fields
------------------------------------
If we use Excel file as Resource then only  one syntax rule:

i) Data Table considers Excel file first Row as Field headers
------------------------------------------------------------------
c) Import Test data from a Database into data table and connect to the Test.

Steps:

i) Create a database

ii) Create tables

iii) Enter Test data
------------------
iv) Create DSN (data source Name)

v) Fetch Test data using SQL commands.

0 comments:

Post a Comment