Blog to understand automation concepts in QTP, Selenium Webdriver and Manual Testing concepts

How to use and load Environment variables in QTP

Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. Environment variables in qtp are very useful to define the environment condition in which QTP is working.

Types of Environment variables

There are two types of Environment variables in QTP

Built-in variable

Built-in variables are QTP defined variables that contains information of Test Properties, computer’s information, Information related to operating system and Action’s property.

User defined variable

Other than environment variable defined in-built in QTP, We can define user defined environment variables. The main purpose of defining user defined variables is to define global variables that can be used throughout test execution irrespective of working with different Actions. So scope of user defined variable is throughout the test execution. This can be of type internal or external if loaded from a file.

Loading of User defined Environment variable


Environment variable can be loaded in following ways:


1.  Through QTP UI

 User defined Environment variables can be created through UI as shown below

Adding new environment Parameter

 Option to export user-defined environment variables and loading of environment variables from external file is also available.


2.  Using ExternalFileName Property and LoadfromFile Method

 Loading of variables from external file as shown above can be done through code:

'Check if an External Environment file is loaded and if not, load it.
fileName = Environment.ExternalFileName
if (fileName = "") Then
    Environment.LoadFromFile("C:\Env.xml")
End If

3.  Using Environment.Value

 Value of environment variable can be extracted at runtime as 
StrEnv=environment.value(envName)

Similarly value of environment variable can be set at runtime as
Environment.value(“envname”)=”some value”

Where to Access Environment Variable 


To access the environment variable, Go to File>Settings>Environment and select built-in or user defined from the drop down.

Accessing environment variables

Use of Environment variable 


  • We can define parameters in QTP using environment variables.
  • Environment variables can act as global variables which can be used across different  tests/actions.
  • We can dynamically load environment variables during start up of QTP execution and can store url, environment, login details in a xml file,which will be loaded each time test is executed.
  • Built- in Environment variables gives us useful information about the test environment and extracting the information can be useful.



FileSystemObject - Manipulation of Files and Files Properties

This post shows what are the basic operation we can do on files using filesystemobject in VBScript. We will discuss on writing to a file and reading from file in next posts.

Below are the tasks we can perform on files using filesystemobject and the properties of file object through which we can extract useful information. 


Tasks Performed on files are as follows: 

1. Creating object for FSO.

2. Verify if file exists.

3. binding to existing file

4. Creating a new text file.

5. Copy or moving a file

6. Deleting a file



Tasks performed on Files
Tasks performed on Files

Properties of File Object
Properties of File Object

How to Work with Folders in QTP using filesystemObject

Below are the tasks which we can perform with folders and properties of folder object which can be used to manipulate folders.

  • Creating object for FSO
  • Verifying existing of an Object
  • Binding to an existing folder
  • Creating a new folder
  • Deleting a folder
  • Copying or moving folder.

Tasks for folder using filesystemobject
Tasks for folder using filesystemobject


Properties of Folder Object
Properties of Folder Object