Environment variables are dynamic in nature, and it can be changed. There are a number of environment variables that can be referenced by programs and can be useful in finding information about their computing environment. HP UFT Environment Variables Micro Focus UFT environment variables can be accessed by all actions, function library, and recovery scenarios.
Types of QTP environment variables
Environment variables are those variables that can be used globally in the tests. There are two types of environment variables
Built-in variables User-defined variables (Has 2 sub-types) Internal External
Built-in Variables
In QTP, built-in variables are pre-defined variables. It enables the user to retrieve the information about the test that is executing and to get information about the O.S (Operating Systems) on which the test is executing. Some of the built-in variables are Action iteration, Operating system, Test directory, local hostnames, Operating system version etc. Go to file -> Settings -> Environment tab to view the environment variable section to see the list of environmental variables.
The values from environment variables can be obtained and used wherever necessary during the run session. Example: MsgBox Environment.Value(“OSVersion”)
User-defined Variables
Before the execution of the test, these are the variables that are defined by the user. It can be used globally across different tests, or they can also be restricted to one test. User-defined variables were classified into two types
Internal External
User defined – Internal Variables: These variables are defined by the user before executing the test and these are available only to a particular test
User defined- External Variables: These variables are defined by the user and it can be used globally across different tests. External variables can be loaded in two ways. It can be done manually before executing the test through environment tab or user-defined screen by inspecting the load variables check box and then by selecting the XML file. You can create a user-defined variable as follows
You can access the variable as follows MsgBox Environment.Value(“Guru99”)
You can create a user-defined variable as follows
You can access the variable as follows MsgBox Environment.Value(“Guru99”)