Types of Environment variables in QTP?

There are two types of Environment variables are available in QTP, They are

Built in

Environment Variables in QTP

User Defined

Built in Environment Variables in QTP are:

 

Name Description
ActionIteration Indicates which action is currently running
ActionName Indicates which action is currently running
ControllerHostName name of the computer that serves as the control
GroupName Indicates Scenario Identification Number
LocalHostName Local Host Name
OS Operating System
OSVersion Operating System Version
ProductDir Indicates Folder path where the product is installed
ProductName Product Name
Productver Product Version
ResultDir Folder Path where the current tests results are saved
ScenorioID Scenario identification number
System TempDir System Temporary Directory
TestDir Path of the folder in which  the tests  is located
TestIteration Indicates which test iteration is currently running
TestName Name of the test
UpdatingActiveScreen Indicates the Active Screen images
UpdatingCheckPoints Indicates Checkpoint properties
UpdatingTODescriptions Indicates Object Test Descriptions
UserName Windows Login UserName
VUserID Virtual user identification Number

Syntax:

Variable  =Environment(“builtin variable or user defined)

Examples:

Msgbox Environment(“OS”)

Msgbox Environment (“GroupName”)

Msgbox Environment (“ActionName”)

Msgbox Environment (“ScenorioID”)

Msgbox Environment (“TestName”)

User Defined Environment Variables in QTP are:

Define User Defined Environment values in XML files and upload it under User defined Environment values and also Load Variables and values from external file

Environment values within and outside the function

Define a Environment values and use it elsewhere in the code wither with in the same function or with in the same test, to use it in other test save environment variables in XML file and upload it to load and use it for the current test

Example :

VarUserName =”Infoyep”

Environment.value(“username”) = VarUserName

If the same Environment values needs to use out side the function then simply use

Environment.value(“username”) wherever it’s required

By using the above method you can store a value anywhere under environment variable and use anywhere any function with in the test.

Leave a Reply

Your email address will not be published. Required fields are marked *