Friday, September 3, 2010

Environment Variables in QTP

There are two types of Environment Variables in QTP
1. Build in Variables
2. User Defined Variables
User Defined Internal
User Defined External

Build-in Variables: These variables are predefined in QTP. : These variables represent the information about the test and the computer. These variables are accessible from all tests, and are designated as read-only.

To get Operating System which we are using--- Environment("OS")
To get the Operating System Version --- Environment("OSVersion")

User Defined Internal Variables: These variables are defined by the User. These variables are defined within the test. These variables are saved with the test and are accessible only within the test in which they were defined.

User-Defined External Variables: These variables are predefined in the active external environment variables files.

To set a value for the VariableName we use
Environment.value("VariableName") = "<Value of the Variable >"

Environment.value("UserId") = "User1"

To get the value of the Environment Variable you can use
ValueOfTheVariable = Environment("VariableName")
ValueOfTheVariable = Environment.value("VariableName")

Msgbox Environment("UserId")

Defining and using Environment Variables:
Go to File > Settings > Environment

No comments:

Post a Comment