Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Advanced UFT 12 for Test Engineers Cookbook
  • Table Of Contents Toc
Advanced UFT 12 for Test Engineers Cookbook

Advanced UFT 12 for Test Engineers Cookbook

4 (3)
close
close
Advanced UFT 12 for Test Engineers Cookbook

Advanced UFT 12 for Test Engineers Cookbook

4 (3)

Overview of this book

This advanced cookbook is designed for software testers and engineers with previous automation experience and teaches UFT (QTP) developers advanced programming approaches. Knowledge of software testing and basic coding (with VBScript in particular) and familiarity with programming concepts are prerequisites.
Table of Contents (13 chapters)
close
close
12
Index

Storing data in the Environment object

The Environment global object is one of UFT's reserved objects and it can be used to store and retrieve both runtime and design-time data.

Note

For a more detailed description of the Environment object, please see the next recipe Retrieving data from the Environment object.

How to do it...

Proceed with the following steps:

  1. To store a parameter at design time, navigate to File | Settings from the UFT menu and then select Environment. From the Variable type list box, select User-defined, as shown in the following screenshot:
    How to do it...
  2. Click on the + button on the right of your Environment window. The Add New Environment Parameter window will open. Enter the new parameter's (variable) name and value:
    How to do it...
  3. Click on the OK button to approve. You will notice that the newly created variable, with its value, now appears on the list. You should pay attention to the Type column, in which it indicates that the variable we just created is Internal:
    How to do it...

What does it mean? A user-defined variable is Internal when we define it through the UFT GUI. It becomes External when either we export the variables to an XML file or define them directly in such a file and later, load the file with the variables and values to the test.

How it works...

Definitions of the types of variable classifications are as follows:

  • Internal variables: When you open an existing test, which has an Internal variable defined, these will be loaded automatically. Changes made to their values during the run session will not be saved. In this sense, the values given to Internal variables using the GUI can be referred to as default values.
  • External variables: When you open an existing test, which has its user-defined variables loaded from an external XML file, these will be loaded automatically. Their values cannot be changed during the run session. In this sense, the values given to External variables can be referred to as constant values.

There's more...

We can also store a value to an Environment variable dynamically from the code. Such a variable will have global scope but will be accessible during runtime only. This means that you will not see it in the list of Internal variables, as shown in this recipe. The procedure is equivalent to using the default Add method of the Scripting.Dictionary object, as shown in the following line of code:

Environment("MyEnvParam") = "MyEnvValue"
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Advanced UFT 12 for Test Engineers Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon