Script

3.3.4 Script

DESCRIPTION

Script - Define start or end of a script (test case). Though the command was introduced as part of the integration with T-Plan Professional, it can be used in a generic way to define the script structure as is common in the QA industry. Script mappings are recognized by the Enterprise report provider and may be used to map the output XML data (or HTML report) onto QA documentation (such as test case specification).

A script in T-Plan terminology, in this case, is equal to a test case. Scripts in general consist of test steps, which represent a set of test instructions describing how to execute the test case. Steps may be specified in T-Plan Robot scripts through the Step command.

The command is intended to be used in pairs [Script <id> start, Script <id> end] to define a block of code which executes a test case. Any output objects generated inside such a block (such as screenshots or warnings) are then associated with the script (test case) ID and this relationship is reflected in the test result data. As a script block validity ends automatically with the file end or with declaration of another "Script start" command, declaration of the script end is optional and may be omitted.

SYNOPSIS

script <id> [start|end]  [name=<displayable_name>]
* Red colour indicates obligatory parameters

OPTIONS

id

- A unique script ID. It may be a number or text. If the test results are to be exported to a third-party test management application, the ID must be an understandable value. Export to T-Plan database (and T-Plan Professional) requires the ID to be a valid script entity number as is described in the Entity Mapping chapter of the T-Plan Robot Integration Reference.

start|end

- Indicates whether the script block starts or ends. It may be also specified as action=\[start|end\]. If the parameter is omitted, the command defaults to start.

name

- An optional displayable name for the script.

RETURNS

The Script command always returns 0 (zero).

EXAMPLES

Script 1 start name="Display http://www.t-plan.com"
Press Windows+R wait=3s
Typeline "http://www.t-plan.com" 
Waitfor match template="tplanlogo.png" method=search timeout=20s
if ({_EXIT_CODE} == 0) {
  Step "Open http://www.t-plan.com in web browser" pass
else {
  Step "Open http://www.t-plan.com in web browser" fail
  Exit 1 
}
Script 1 end 

- An example of script number 1 which opens the T-Plan web site in the default web browser on Windows. The script uses image search to verify that the page was displayed successfully. If the T-Plan logo is detected on the desktop the script records a passed step result. Otherwise, a failed step is recorded and the script exits with a code of 1 to indicate failure.