Relevant for: GUI tests and scripted GUI components
UFT can insert a value from the Environment variable list, which is a list of variables and corresponding values that can be accessed from your test or component. Throughout the run session, the value of an environment variable remains the same, regardless of the number of iterations, unless you change the value of the variable programmatically.
When you add an environment variable to a GUI test, it is available to all actions in the test and all steps in the test.
If you add an environment variable to a component, it is available only to that component, even if the component is part of a BPT test. Environment variables cannot be used to pass data from one component to another in a BPT test.
Tip: Environment parameters are especially useful for localization testing, when you want to test an application where the user interface strings change according to the selected language. Environment parameters can be used for testing the same application on different browsers. You can also vary the input values for each language by selecting a different data table file each time you run the steps.
Variables that represent information about the test or scripted component and the computer on which they are run, such as Test path and Operating system. These variables are accessible from all tests and scripted components, and are designated as read-only.
ALM provides a set of built-in variables that enable you to use current information about the test or scripted component and the UFT computer running your test or component. These can include the test or component name and path, the operating system type and version, and the local host name.
For example, you may want to perform different checks in your test or component based on the operating system being used by the computer that is running the test or component. To do this, you could include the OSVersion built-in environment variable in an If statement.
You can also select built-in environment variables when parameterizing values.
UFT also has a set of predefined environment variables that you can use to set the values of the Record and Run Settings dialog options. You should not use the names of these variables for any other purpose. For details, see the sections on how to define record and run settings for Windows-based and Web-based applications in the Unified Functional Testing Add-ins Guide.
If you use an Environment statement to retreive the operating system value on Windows Server 2016 Standard, it returns an incorrect value of Windows Server Technical Preview.
User-defined internal environment variables are defined within the test or component. These variables are saved with the test or component and are accessible only within the test or component in which they were defined.
You can create or modify internal, user-defined environment variables for your test or component in the:
Environment pane of the Test or Component Settings dialog box
Parameter Options dialog box
You can also create environment output values, which retrieve values during the test run and output them to internal environment variable parameters for use in your test or component.
User-defined external environment variables are predefined in the active external environment variables file. You can create as many files as you want and select an appropriate file for each test or component, or change files for each run. External environment variable values are designated as read-only within the test or component.
External environment variable files are comprised of a list of variable-value pairs in .xml format. You select the active external environment variable file for a test or component in the Environment pane of the Test Settings or Component Settings dialog box. Then you can use the variables from the file as parameters.
You can set up your environment variable XML files manually, or you can define the variables as internal environment variables in the Environment pane of the Test Settings dialog box and use the Export button to create the .xml file with the correct structure.
For details on creating and using user-defined external environment variable files see, Use user-defined external environment variables.