parameterization in uft

Parameterization in UFT

What is Parameterization?

Replacing constant (Fixed) values with Parameters
----------------------------------------------------
Purpose of Parameterization

    To pass single dynamic value

    To pass multiple values
---------------------------------------------------------
What is Data driven Testing?

Testing same operations with multiple sets of Test Data
------------------------------------------------

Why Data driven Testing?

    For Positive and Negative Testing
    Check the Reliability of the System
---------------------------------------------------

Relation between Parameterization and Data driven Testing

How to parameterize?

We can use either VBScript variables or Constants or Arguments or Environment Variables or
Action Parameters or Data Table Parameters or Dictionary keys as parameters.

Ways of Parameterization
----------------------------------
i) Generate and Pass values using Loop Statements

Possibilities
--------------
a) We can generate sequential Numbers (1, 2, 3.../50, 51, 52....)

b) We can generate Logical Numbers (1, 3, 5.../2, 4, 6.../10, 20, 30....)

-----------------------
Limitations

a) We can't generate desired numbers (1, 7, 20, 45.....)

b) We can't generate string type data (User Name, Password, city name etc...)
----------------------------------------
Ex:

'Open 1 to 10 Orders

For OrderNo = 1 To 10
Window("Flight Reservation").Activate @@ hightlight id_;_1574716_;_script infofile_;_ZIP::ssf1.xml_;_
Window("Flight Reservation").WinButton("Button").Click @@ hightlight id_;_67982_;_script infofile_;_ZIP::ssf2.xml_;_
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON" @@ hightlight id_;_133558_;_script infofile_;_ZIP::ssf3.xml_;_
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNo @@ hightlight id_;_133578_;_script infofile_;_ZIP::ssf4.xml_;_
wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click @@ hightlight id_;_133576_;_script infofile_;_ZIP::ssf5.xml_;_
Next
---------------------------------------------------
'Open even numbers
For OrderNo = 2 To 10 Step 2
Window("Flight Reservation").Activate @@ hightlight id_;_1574716_;_script infofile_;_ZIP::ssf1.xml_;_
Window("Flight Reservation").WinButton("Button").Click @@ hightlight id_;_67982_;_script infofile_;_ZIP::ssf2.xml_;_
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON" @@ hightlight id_;_133558_;_script infofile_;_ZIP::ssf3.xml_;_
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNo @@ hightlight id_;_133578_;_script infofile_;_ZIP::ssf4.xml_;_
wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click @@ hightlight id_;_133576_;_script infofile_;_ZIP::ssf5.xml_;_
Next
--------------------------------------
'Open first 10 orders in reverse order
For OrderNo = 10 To 1 Step -1
Window("Flight Reservation").Activate @@ hightlight id_;_1574716_;_script infofile_;_ZIP::ssf1.xml_;_
Window("Flight Reservation").WinButton("Button").Click @@ hightlight id_;_67982_;_script infofile_;_ZIP::ssf2.xml_;_
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON" @@ hightlight id_;_133558_;_script infofile_;_ZIP::ssf3.xml_;_
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNo @@ hightlight id_;_133578_;_script infofile_;_ZIP::ssf4.xml_;_
wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click @@ hightlight id_;_133576_;_script infofile_;_ZIP::ssf5.xml_;_
Next
----------------------------------------
'open 1 to 5 orders except 4th Order
For OrderNo = 1 To 5 Step 1
If OrderNo <> 4 Then
Window("Flight Reservation").Activate @@ hightlight id_;_1574716_;_script infofile_;_ZIP::ssf1.xml_;_
Window("Flight Reservation").WinButton("Button").Click @@ hightlight id_;_67982_;_script infofile_;_ZIP::ssf2.xml_;_
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON" @@ hightlight id_;_133558_;_script infofile_;_ZIP::ssf3.xml_;_
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNo @@ hightlight id_;_133578_;_script infofile_;_ZIP::ssf4.xml_;_
wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click @@ hightlight id_;_133576_;_script infofile_;_ZIP::ssf5.xml_;_
End If
Next
--------------------------------------
'open 1 to 5 orders except 4th Order
For OrderNo = 1 To 5 Step 1
If Not OrderNo = 4 Then
Window("Flight Reservation").Activate @@ hightlight id_;_1574716_;_script infofile_;_ZIP::ssf1.xml_;_
Window("Flight Reservation").WinButton("Button").Click @@ hightlight id_;_67982_;_script infofile_;_ZIP::ssf2.xml_;_
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON" @@ hightlight id_;_133558_;_script infofile_;_ZIP::ssf3.xml_;_
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNo @@ hightlight id_;_133578_;_script infofile_;_ZIP::ssf4.xml_;_
wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click @@ hightlight id_;_133576_;_script infofile_;_ZIP::ssf5.xml_;_
End If
Next
-------------------------------------------
'open 1 to 10 orders except 4th and 7h Orders
For OrderNo = 1 To 10 Step 1
If OrderNo <> 4 And OrderNo <> 7 Then
Window("Flight Reservation").Activate @@ hightlight id_;_1574716_;_script infofile_;_ZIP::ssf1.xml_;_
Window("Flight Reservation").WinButton("Button").Click @@ hightlight id_;_67982_;_script infofile_;_ZIP::ssf2.xml_;_
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON" @@ hightlight id_;_133558_;_script infofile_;_ZIP::ssf3.xml_;_
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNo @@ hightlight id_;_133578_;_script infofile_;_ZIP::ssf4.xml_;_
wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click @@ hightlight id_;_133576_;_script infofile_;_ZIP::ssf5.xml_;_
End If
Next
------------------------------------------------
ii) Dynamic Submission 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\","open"
Dialog("Login").Activate @@ hightlight id_;_198992_;_script infofile_;_ZIP::ssf6.xml_;_
Dialog("Login").WinEdit("Agent Name:").Set Agent @@ hightlight id_;_133510_;_script infofile_;_ZIP::ssf7.xml_;_
Dialog("Login").WinEdit("Password:").Set Password @@ hightlight id_;_133508_;_script infofile_;_ZIP::ssf8.xml_;_
Wait 2
Dialog("Login").WinButton("OK").Click @@ hightlight id_;_133506_;_script infofile_;_ZIP::ssf9.xml_;_
Window("Flight Reservation").Close
Next

'It is used for entering verification code
---------------------------------------

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/Excel) and connect to the Test

    c) Import test data from a database and connect to the Test

    d) Using Data Table methods and programmatic statements (Hybrid)

Steps for Data Driven Testing using Data Table

1) Generate the basic Test and run it once

2) Enter/Import test data into Data Table

3) Connect Test Data with the Test

    Using Editor View

Syntax:

DataTable("Column Name"/Column Id, Sheet Name/Sheet Id)

Ex:
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\flight\app\flight4a.exe","","C:\Program Files\HP\Unified Functional Testing\samples\flight\app\","open"
Dialog("Login").Activate @@ hightlight id_;_262356_;_script infofile_;_ZIP::ssf1.xml_;_
Dialog("Login").WinEdit("Agent Name:").Set DataTable(1, 1) @@ hightlight id_;_592436_;_script infofile_;_ZIP::ssf2.xml_;_
Dialog("Login").WinEdit("Password:").Set DataTable(2, 1) @@ hightlight id_;_526904_;_script infofile_;_ZIP::ssf3.xml_;_
Wait 2
Dialog("Login").WinButton("OK").Click @@ hightlight id_;_1706502_;_script infofile_;_ZIP::ssf4.xml_;_
Window("Flight Reservation").Close
---------------------------------------
    Or
    Using keyword view
    Or
    Using Data Driver

4) Run the Test
----------------------------------------------

Import test data from a database 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 Statements
------------------------------------------
Default location for storing DSN

C:\Program Files\Common Files\ODBC\Data Sources


Using Data Table methods and programmatic statements (Hybrid)

Ex:
'Create New sheet in Run-Time data table to import Test Data
DataTable.AddSheet "Login"
'Import test data from an external file
DataTable.ImportSheet "C:\Documents and Settings\gcreddy\Desktop\input.xls", 1, "Login"

RowsCount= DataTable.GetSheet(3).GetRowCount

For i = 1 To RowsCount Step 2
DataTable.SetCurrentRow(i)
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\flight\app\flight4a.exe","","C:\Program Files\HP\Unified Functional Testing\samples\flight\app\","open"
Dialog("Login").Activate @@ hightlight id_;_1575518_;_script infofile_;_ZIP::ssf1.xml_;_
Dialog("Login").WinEdit("Agent Name:").Set DataTable(1, 3) @@ hightlight id_;_592526_;_script infofile_;_ZIP::ssf2.xml_;_
Dialog("Login").WinEdit("Password:").Set DataTable(2, 3) @@ hightlight id_;_4196862_;_script infofile_;_ZIP::ssf3.xml_;_
Wait 2
Dialog("Login").WinButton("OK").Click @@ hightlight id_;_527010_;_script infofile_;_ZIP::ssf4.xml_;_
Window("Flight Reservation").Close
Next
------------------------------------------------
'Read test data from an external file and export Test Result to external file

'Create New sheet in Run-Time datatable to import Test Data
DataTable.AddSheet "Login"
'Import test data from an external file
DataTable.ImportSheet "C:\Documents and Settings\gcreddy\Desktop\input.xls", 1, "Login"

RowsCount= DataTable.GetSheet(3).GetRowCount

For i = 1 To RowsCount Step 1
DataTable.SetCurrentRow(i)
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\flight\app\flight4a.exe","","C:\Program Files\HP\Unified Functional Testing\samples\flight\app\","open"
Dialog("Login").Activate @@ hightlight id_;_1575518_;_script infofile_;_ZIP::ssf1.xml_;_
Dialog("Login").WinEdit("Agent Name:").Set DataTable(1, 3) @@ hightlight id_;_592526_;_script infofile_;_ZIP::ssf2.xml_;_
Dialog("Login").WinEdit("Password:").Set DataTable(2, 3) @@ hightlight id_;_4196862_;_script infofile_;_ZIP::ssf3.xml_;_
Wait 2
Dialog("Login").WinButton("OK").Click 


If Window("Flight Reservation").Exist(12) Then
    Window("Flight Reservation").Close
    DataTable(3, 3) = "Login Successful - Passed"
    Else
    DataTable(3, 3) = "Login Unuccessful - Failed"
    SystemUtil.CloseDescendentProcesses
End If
Next
DataTable.ExportSheet "C:\Documents and Settings\gcreddy\Desktop\Result1.xls", "Login"
-----------------------------------------------
 

1 comments:

Post a Comment