UFT Tutorial 12 - Parameterization Part-2 and Environment Variables

UFT Tutorial 12 - Parameterization Part-2, Environment Variables

Usage of Data Table:

1) Enter Test Data directly in to Data Table and connect to the Test.

2) Import Test data from files (Excel/Text) and connect to the Test.

If you want to import test data from a text file, there are 2 syntax rules,

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

ii) Tab space is the delimiter between two fields
If you want to import test data from an excel file,

Data Table considers Excel sheet first row as column headers.
3) Import Test data from a database and connect to the Test.


i) Create a Database

ii) Create Tables

iii) Enter Test Data
iv) Create DSN (Data Source Name)

v) Fetch Test data using SQL commands.
4) Data driven Testing using Data Table methods and programmatic statements

'Create new sheet in Run-time Data Table
DataTable.AddSheet "Login"
'Import data from an external file
DataTable.ImportSheet "C:\Users\G C REDDY\Desktop\Input.xlsx", 1, 3
RowCount = DataTable.GetSheet("Login").GetRowCount
Msgbox RowCount
For i = 2 To RowCount Step 2
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe"
WpfWindow("HP MyFlight Sample Application").WpfEdit("agentName").Set DataTable("Agent", "Login")
WpfWindow("HP MyFlight Sample Application").WpfEdit("password").Set DataTable("Password", "Login")
wait 2
WpfWindow("HP MyFlight Sample Application").WpfButton("OK").Click
WpfWindow("HP MyFlight Sample Application").Close
Environment Variables

What are Environment variables?

Environment variables are global variables depends on local system operating environment.

Purpose of Environment variables

                Centralized maintenance of variables
                Tests Portability

Types of Environment variables

                Built-in Variables
                User Defined Variables

Create Environment (User defined) variables

Associate Environment variables file to UFT

Access Environment variables



Msgbox Environment("OS")
Msgbox Environment("ProductDir")
Edit Environment variables

Delete Environment variables
Environment.LoadFromFile "C:\Users\G C REDDY\Desktop\abcd.xml"
SystemUtil.Run Environment("AppPath")
WpfWindow("HP MyFlight Sample Application").WpfEdit("agentName").Set Environment("Agent")
WpfWindow("HP MyFlight Sample Application").WpfEdit("password").Set Environment("Password")
wait 2
WpfWindow("HP MyFlight Sample Application").WpfButton("OK").Click
WpfWindow("HP MyFlight Sample Application").Close
'Load Shared object Repository file at Run-time
RepositoriesCollection.Add "Path of the Shared Repository file"

'Load Function Library file at Run-time
ExecuteFile "Path of the Function Library file"

'Load Environment Variables file at Run-time
Environment.LoadFromFile "path of the Environment variables file"