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 "Monika"
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.
No comments:
Post a Comment