Reading:  

Quick Test Professional - The starters Guide


Environment Variables

Environment variables in QTP are same as to global variables which can be accessed through any part of the code. These variables can prove to be useful when we want a variable to be shared across many reusable tasks and functions.

  Environment variable types are:

  1. Built in variables
  2. User Defined variables:
  • Internal
  • External 

Built in variable:

are designated as read-only, which represent the information about the test on which the test is run, such as Test path and Operating system.

Syntax: Variable = Environment ("variable name")

The Environment Variable names can be accessed by:

Go to "File" select "Test Settings" select "Environment" Tab.

Environment QTP

 

Internal User defined variable:

This variables are saved with the test and are accessible within the test only.

To save the "User Defined Variables", Select "User Defined" in the Environment Tab Window and click on "+" icon; enter the Name and Value as shown below

Internal user defined variables QTP

 

External User defined variable:

This can be created using a list of variable-value pairs in an external file format as .xml.

It can be loaded into the test as shown:

External User defined variable: QTP

 

Environment variables: Methods and Properties:

  • ExternalFileName Property
  • LoadFromFile Method
  • Value Property

 

ExternalFileName:

This is used to get the name of the loaded external environment variable file mentioned in the Environment pane of the Test Settings dialog box. 

If there is no external environment variable file is loaded, then it returns an empty string.

Syntax:  Environment.ExternalFileName

x= Environment.ExternalFileName 
print x


 

LoadFromFile:

This is used to loads environment variable file which is specified.

The environment variable file must be an XML file.

Syntax: Environment.LoadFromFile (Path)

 

Value Property:

This is used to retrieves the environment variables value.

We can also set the value only for user-defined environment variables.

Syntax:

 To setting the value of a user-defined environment variable:

Environment.Value(VariableName) = NewValue

Description

In this tutorial, we will get to know Quick test professional. At the time of writting QTP is at version 12.2. This tutorial is subdivided into multiple parts as shown below

  • What is QTP
  • Automating tests
  • Environment
  • Recording and Playback
  • Object Repository
  • Actions
  • Data Table
  • Checkpoints in QTP
  • Synchronization
  • Smart Identification
  • Debugging and Error handling
  • Recovery Scenarios
  • Environment Variables
  • Library Files
  • Test Results
  • GUI Objects
  • Virtual Objects
  • Accessing Databases
  • Working with XML
  • Descriptive Programming
  • Automation Object Model
  • A work on Frameworks

Leave your feedback for us, Feedback help us improve our tutorials.

 



Prerequisites

Some knowledge on Windows OS and VB Script is recommended

Audience

Students who wish to learn QTP

Learning Objectives

Learn QTP

Author: Subject Coach
Added on: 16th Mar 2015

You must be logged in as Student to ask a Question.

None just yet!