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

Retrieving data from the Environment object

This recipe will show you how to retrieve data from the Environment object, which is a kind of dictionary that stores key-value pairs. As we will see, unlike a regular dictionary, the Environment object stores two types of variables:

  • Built-in
  • User-defined

Built-in Environment variables give access to two types of information:

  • Static data such as the OS, OSVersion, LocalHostName, SystemTempDir, ProductDir (where UFT is installed), ProductName, ProductVer (UFT version), UserName (the Windows login name), and several settings such as UpdatingCheckpoints and UpdatingTODescriptions. In addition, we can retrieve information about the current test, such as TestName and TestDir (the path to the current test(s) from the Environment object).
  • Runtime data such as TestIteration, ActionName, and ActionIteration can be retrieved via the Environment object during runtime. The iteration number can be useful, for instance, when we need to perform an initialization procedure that should be done only once. In this case, the iteration number must be equal to the TestIteration parameter value.

Getting ready

Create a user-defined Environment variable named MyEnvParam (see the previous recipe, Storing data in the Environment object).

How to do it...

The following code shows how to retrieve either a built-in or a user-defined variable:

Print Environment("TestDir")
'Prints the Built-in TestDir (path) Environment variable to the console
Print Environment("MyEnvParam")
'Prints the User-defined MyEnvParam Environment variable to the console

How it works...

Similar to the workings of the Scripting.Dictionary object, by accessing an existing key, the Environment object returns its paired value.

See also

User-defined Environment variables can be stored in an XML file and dynamically loaded during the runtime session. Refer to the Using global variables (Environment) recipe of Chapter 8, Utility and Reserved Objects.

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