Pages

Custom Search

Environment Variables in QTP

Environment Variables in QTP

These are global variables; if you want to use some variables globally (From number of tests) declaring as global variables is better. If we declare as local variables in number of tests, modifications are difficult.

Types of Environment variables:

1. Built in variables: These are system defined variables, we can access from all tests but these are designed as read only.

2. User defined variables: Variables that we predefine in the active external environment variables file. We can create as many files as we want and we can change values of variables.

Usage of environment variables:

Syntax: 
Variable = Environment("environment variable name")

Ex: 

X=Environment ("ActionName")
Msgbox x

Example Script: 

ProductDir =environment ("ProductDir")
app= "\samples\flight\app\flight4a.exe"
Systemutil.Run ProductDir & app
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "kajal"
Dialog("Login").WinEdit("Password:").SetSecure "4b3c86f2107ff565cc195ba6c24739091b656407"
Dialog("Login").WinButton("OK").Click

Creating user defined environment variables:

Navigation: 

File > settings > Environment > select variable type as user defined > click add icon (+) > enter variable name & Value > click ok (like this we can create number of variables) > click export > browse path & enter file name, save with xml extension > click ok.

Associating environment variable file:

Navigation: 
File > settings >Environment > select variable type as user defined > check "load variables and values from the external file" > browse path of the xml file > click apply & ok.

Or 

We can load environment file directly 

Environment.loadfromfile"path of the xml file"

Usage of user defined Environment variables:

Associate environment file to current test:
Variable = Environment ("Variable Name")

X=environment ("city")
Msgbox x

Modifying Environment files:

Select XML file>open with notepad>modify the values>Save.

4 comments:

Anonymous said...

Admiring the dedication you put into your blog and detailed information you present.
It's awesome to come across a blog every once in a while that isn't the same out
of date rehashed material. Great read! I've saved your site and I'm adding your RSS feeds to my Google account.
Visit my website - click through the next web page

Anonymous said...

Excellent write-up. I absolutely appreciate
this site. Keep it up!
Also visit my homepage : insurance

Anonymous said...

Hi there, I enjoy reading through your article. I like to write
a little comment to support you.
Look at my webpage - seo company india

Anonymous said...

It's actually a cool and helpful piece of info. I am happy that you shared this useful info with us. Please stay us informed like this. Thanks for sharing.
search engine optimization firms