T-Plan Robot Documents > T-Plan Robot Enterprise v2 Tutorial

Automatic execution

In the previous topic we discussed manual execution in the T-Plan Robot Enterprise GUI. It however doesn't make much sense to run scripts this way all the time. In an ideal automation scenario we want to develop a script and then integrate Robot with the system scheduler or a test management tool to execute it automatically against new AUT builds and/or at scheduled intervals.

T-Plan Robot Enterprise offers two integration interfaces, the command line interface (CLI) and the programming Java API. As the Java API will be discussed later on, for the purpose of this topic we will define automatic execution as an unattended script execution started from the command line interface (CLI). In simple words, you pass the necessary parameters through the CLI options and T-Plan Robot will execute the script and report the result. The most important CLI options (switches) are:
  • -r/--run specifies the test script file to be executed and it is the only mandatory switch for automatic execution. It accepts both plain scripts (typically .tpr extension) as well as Java source code (.java). The file may be either absolute (with full file path given) or relative to the installation folder.
  • -c/--connect defines the test environment (remote desktop) to connect to. As scripts may also connect on their own through the Connect command, this parameter is optional. The argument must be a valid URL in form of [protocol]://[server]:[port]. The protocol is mandatory and defines the desktop technology. For example, to connect through VNC use "RFB" or "rfb". The server name is also mandatory and it must be either a resolvable server name, a numeric IP address or the loop back name ("localhost"). The port is optional and if omitted the tool falls back to the default port number for the given technology (5900 for VNC). If the server requires a user name or password, they must be specified through the -u/--user or -p/--password options.
  • -n/--nodisplay suppresses the GUI and runs in CLI only (so called "CLI mode"). Advantages of this mode are lower memory requirements and ability to run on terminals without graphic environment. Disadvantages are limited control over the execution and missing visual contact with the desktop.
  • Behavior of the script and/or the tool itself may be customized through the -v/--variable (already mentioned in one of the previous topics), -o/--option, --fromlabel, --tolabel and --nooutput switches. See the T-Plan Robot Enterprise CLI Reference for more.
Let's demonstrate the CLI functionality on the latest version of our calculator.tpr script. In the videos demonstrated so far we have executed the script on a local VNC server running on port 5901 on Ubuntu Linux and on a VNC server running on a Windows XP virtual machine with IP 192.168.100.3. To execute the script one would run:
  • Linux:  java -jar robot.jar -r calculator.tpr -c rfb://localhost:5901 -p welcome -v OS=Linux
  • Windows:  java -jar robot.jar -r calculator.tpr -c rfb://192.168.100.3 -p welcome -v OS=Windows
These examples presume that the calculator.tpr script is located in the T-Plan Robot Enterprise installation folder and that the VNC server password is "welcome". As the -n/--nodisplay switch is not specified, the GUI opens up and shows a simple window with the start time out (15 seconds by default). Then the script gets executed. In this phase you are free to interact with the GUI and interfere with the script in any way; be however aware that any such action will turn the execution into a manual one and the tool will not exit automatically. Unless this happens and the script finishes on its own, the tool counts down the shut down timeout, dismisses the GUI and terminates the application. It returns to the underlying OS either the default value of 0 (zero) or the custom value specified by the script through the Exit command.

When the example commands are run with the -n/--nodisplay switch, the sequence is similar save that the progress is reported into the console (command prompt). The tool counts down the start timeout first. Unlike in GUI this step can not be skipped. While the script is being executed, it may only be stopped through Ctrl+C or resumed when the script pauses the execution through the Pause command. When the script finishes, the shut down sequence is counted down and the application exits.

The start and shut down time outs are intended to provide an opportunity to interrupt the automatic process before the script is started or to prevent the application from exiting. The time out values are configurable through the Scripting->Execution panel of the Preferences window. To switch off a time out set its value to zero. To set a custom time out value temporarily for a particular script execution use the -o/--option switch. For example, to set up the start time out to 3 seconds include "-o scripting.delayBeforeAutomaticExecutionSeconds=3" in your command.