Environmental Variables in QTP
Environment variables in QTP are nothing but the variables which are available all across the project. these are similar to the global variables. Environment variables are the special variables which stores environmental values.Throughout the test run, the value of an environment variable remains the same, regardless of the number of iterations, unless we change the value of the variable programatically in your script.
There are two type of Environmental variables-
- Built-in Environmental variables
- User defined Environmental variables
Built-in Environmental variables-Built in variables provided by QTP. There are various functions comes under built in environmental variables. Following are the list of some of the built in environmental variables
- ActionName-Returns the name of action
- LocalHostName-Returns a host name
- OS-Returns the OS name
- OSVersion-Returns OS version
- ProductDir- Returns the name of product directory
- ProductName-Returns the name of product
- ProductVer- Returns the verion of the product
- UserName-Returns the user name
- TestName- Returns the name of the test under execution
- TestIteration-Returns the Iteration of the test
User Defined Variables- User defined variables are categorized into two types.
- Internal User defined variables- This type of variables defined in test and accessible with in the same test.The scope of user-defined variables are upto the same test.
URL=Environment.Value(“test_url”) Systemutil.Run “iexplore.exe”,URL
- External user defined variables- These are the variables that we pre-define in the active external environment variables file.
These can be created using a list of variable-value pairs in an external file in .xml format.
Environmental variables are normally used to avoid excess number of variables.use of Environmental variables helps to make changes in variables values by making small changes.