Predefined variables
Predefined variables provide useful data about the test environment, execution
context and script properties. Their name typically starts with
underscore '_' and they are created by various components participating
in the automation framework, such as test script interprets, individual
command handlers, image comparison algorithms and others. These
variables can be freely called in any plain test script. They can be
also modified by a script and some of them were even designed to
provide a certain way of customization. There's also a group of
variables which are being updated on a continuous bases and should be
used in a "read only" way.
This topic lists just a few most
important ones. We recommend you to have a look at the table of predefined
variables in the Var command specification to get an overview of
what is available. For now you may at least have a look at the Variables
GUI component (on the picture) which displays variables
from compilation or execution of the script in active editor.
Template path (_TEMPLATE_DIR ) and output path (_REPORT_DIR)
allow
to
customize the input/output directories. Template path is source directory
containing
template images for image comparison. Commands employing image
comparison will search this directory for all templates specified by
relative path. Output path
serves as default target folder for all outputs produced by the script
such as screen shots and reports (if specified by relative path). Both
variables default to the user home folder or the folders configured in
the Scripting->Language
panel of the Preferences
window. To customize the paths for a particular script either redefine
them in the code manually (as you see it in the editor on the picture)
or take advantage of the Settings GUI panel.
Command exit code (_EXIT_CODE)
stores
numeric
exit code of the last executed command or procedure. It
is a convention that commands return 0 on success or an error number
otherwise. Testing of the exit code is therefore an important mechanism
allowing to check whether the script and/or the tested application
behave as expected. You will see examples later on in this tutorial.
Current time (_CURTIME)
is
a
dynamic variable which gets resolved into the actual time in
milliseconds elapsed since midnight of January 1, 1970 UTC. It allows
to
measure time spent in a command or a block of commands. It can be also
used to create a unique string, for example a file name.
Environment variables
form by far the largest group. The _TIME and _DATE
variables store time and date of the script execution start. The _FILE
and _FILENAME ones contain full and short name of the executed/compiled
test script. Properties of the connected test environment (desktop) are
specified through the _MACHINE, _PORT, _PROTOCOL, _URL,
_DESKTOP_WIDTH and _DESKTOP_HEIGHT variables.
Product variables specify
the product name (T-Plan Robot or T-Plan Robot Enterprise), version,
home page and installation folder. This information can be used for
example in report description to store details of the test environment.
There's a number of command created
variables which are not present in the list. They are defined by
particular command handlers on execution. For example whenever you
perform a successful image search, coordinates of the located GUI
component are made available in form of variables. Refer to the
individual command specifications for details.
|