Variable is a place
holder which stores a single or multiple values. Likewise Environment variables
are dynamic "object" on a computer that can store a value and which in
turn can be referenced by one or more software programs in Windows. I mean
these dynamic values are reused. Environment variables are dynamic in nature,
and it can be changed. There are number of environment variables that can be
referenced by programs and can be useful in finding information about their
computer environment. Environment variables are those variables that can be used globally in the tests.
QTP Environment Variables
In parameterization we
have discussed about environmental parameters. These Environmental variables
are tested using this environmental parameterization. QTP environment variables
can be accessed by all actions, function library, and recovery scenarios.
Types
of QTP environment variables
There are two types of environment variables
- Built-in variables
- User defined variables
Built-in
Variables:
In
QTP, built-in variables are pre-defined variables. They are already defined and
stored in QTP. It enables the user to retrieve the information about the test
that is executing and to get information about the Operating systems on which
the test is executing. Here are few of the built-in variables that we use
regularly in QTP are Action iteration, Operating system, Test directory, local
host names, Operating system version etc.
So
in order to use these built in variables we undergo these navigation
Go
to file > Settings > Environment tab to
view the environment variable section to see the list of environmental
variables.
The
values from environment variables can be obtained and used wherever necessary
during the run session.
Example: MsgBox Environment.Value("OS Version")
User-defined
Variables
These are the variables that are defined by the user. User can define these variables before the
execution of test. It can be used globally across different tests, or they can
also be restricted to one test. User-defined variables were classified into two
types
- Internal
- External
User
defined - Internal Variables: These variables are defined by the
user before executing the test and these are available only to a particular
test
User
defined- External Variables: These variables are defined by the
user and it can be used globally across different tests. External variables can
be loaded in two ways. It can be done manually before executing the test
through environment tab or we can use user-defined
screen by inspecting the load variables check box and then by selecting the XML
file.
In order to
define a user defined variable we have to access the variable as follows
Go to Test Settings > Select Environment option> Select variable type as User Defined > Click on ADD option > It will open an add new environment Parameter Name it as Guru99 And in the value text box name it as Testing > Click ok > Next Click Apply > Click Ok
If you want to access the guru99 environment variable then we have access in this way.
MsgBox Environment.Value("Guru99")
No comments:
Post a Comment