Before understanding the concept of environment variables in UFT, let’s first try to understand what actually environment variables are.
Environment variables are variables that describe the environment in which programs run. They are used by all kinds of programs to answer questions like: What is the name of the computer? What is the name of the Operating System? What is the name of the current user account running on the machine? What is my current working directory? Where is Windows installed? Where are the temporary files stored on this computer? and many more.
In Windows, environment variables have a name and its value. For example, the variable windir (“Windows directory”) may have the value “C:\Windows” or another path where Windows has been installed.
You can view your machine environment variables by accessing System Properties and then click on the Environment Variables button.
Environment Variable window will appear.
Environment Variables in UFT/QTP
Types of environment variables in UFT/QTP
- Built-in environment variables
- User-Defined Internal Environment Variables
- User-Defined External Environment Variables
Built-in environment variables
User-Defined Internal Environment Variables
- Manually define User-defined Environment Variable in the Environment Tab
- Manually define a user-defined environment variable in the code itself
Manually define User-defined Environment Variable in the Environment Tab
In the Environment tab, select the variable type as “User-defined” and click on the “+” icon. Enter the name of the variable in the name text box and its value in the Value text box and click the OK button. It will be added to the User-defined environment variable list.
Manually define a user-defined Environment variable in the code itself
This is the most convenient way to manually define Environment variables at any step in your test script or function and used its value across the project.
Syntax: Environment.Value(“Name of Environment Variable”) = “Required value”
Example : Environment.Value(“Language”)= “English”
To get its value,write Msgbox Environment(“Language”)
User-Defined External Environment Variables
The user-defined external environment variable is itself a topic of discussion that I will discuss in the next post.
- How To Use Dictionary Object in UFT With Examples
- Micro Focus UFT Tutorial – An Overview of UFT
- DataTable in UFT One | Example of Datatable Methods
- How to Use Visual Relation Identifier in UFT with Example
- Action Input And Output Parameters In UFT
- Understand Local And Shared Object Repository in UFT
- How To Add Page Checkpoint in UFT