Types of the Environment Variables in QTP

QTP has basically 2 types of environment variables.


  • Built in - e.g OS - operating system information - This is read only
  • User Defined - User can define his own variables - This can be edited or modified.
User defined variables can be loaded from external variables as well. When you load it from the external file, Variables can not be edited.

To create user defined variables, you have to go to the settings of the test and click on environment Tab.
Select variable type as "User defined". Then add any variable and it's value.

Example -

'Create environment variable at runtime -
Environment.Value("MyDirectory") = "c:\test"

Environment.LoadFromFile "c:\Env.ini"   ' Load varaibles from ENV.ini

Format of ini file should be like this -

[Environment]
 
   var1=abcd
   var2=xyz

[Environment]