UFT Class 16

UFT Class 16

(Environment Variables)

What are Environment Variables?

They are global variables depends on operating system environment.

Purpose of Environment Variables

Centralized Maintenance of Variables

Tests portability
Note 1: Whenever we want to use any variable in multiple Tests then choose Environment variables.

Note 2: Whenever you want use any variable in a single Test then no need to choose Environment variables.

Tests portability:

Executing Tests from different machines.

Types of Environment Variables

a) Built in variables

b) User defined variables


i) Create Environment (User defined) variables and export to XML

ii) Associate Environment Variables file
Load Environment Variables file during execution

iii) Access environment Variables

Msgbox Environment(“OS”)
Msgbox Environment(“ProductDir”)

iv) Modify Environment variables (If required)

v) Delete Environment Variables (Optional)
Note: Environment variables are case sensitive.

Environment Veriables

1) Navigation for Creating Environment Variables

File menu
> Settings
> Environment
> Select variable type as “User defined”
> Click Add icon
> Enter Variable name and value
> Click OK
(Again click Add icon if we want to create multiple variables)

> Click Export

> Browse path to store XML file

> OK

2) Navigation for Associating Environment Variables file

File menu

> Settings

> Environment

> select Variable as “User defined”

> Check “Load variables and values from external file”

> Browse path of the XML file

> Apply > OK


SystemUtil.Run Environment(“AppPath”)
Dialog(“Login”).WinEdit(“Agent Name:”).Set Environment(“Agent”)
Dialog(“Login”).WinEdit(“Password:”).Set Environment(“Password”)
Wait 2

‘Load Environment Variables file during execution

Environment.LoadFromFile “C:\Users\G C Reddy\Desktop\abcd.xml”

Note: without UFT tool also we can create Environment variables

> Launch Notepad

> Type tags

> Sava as XML file

Tags of Environment variables file

Environment open tag end tag

Variable open and close tag

Name open and close tag

Value open and close tag




Follow me on social media: