Scripting Languages

T-Plan Robot fully supports two different scripting languages:

  1. Proprietary scripting language (.tpr). The language is simple, text-based and close to spoken English and thus easy to understand.
  2. Java scripts (.java). There is a Java Script API allowing to write and execute test scripts in the Java language

It is important to realise that both script formats support the same set of commands (user actions) specified by the scripting language specification. Most scripting language commands have their counterpart methods in the Java API and there's even a way to convert ordinary scripts to Java code (will be discussed later on).

One of the frequently asked questions is what is better, ordinary scripts (.tpr) or Java? Well, it depends. Someone may favour ordinary scripts, or someone may favour Java programming, whilst others may prefer to mix these approaches. All combinations are fully supported by the tool, with even conversion support from .tpr scripts to Java. There are advantages and disadvantages: 

  • Proprietary scripts (.tpr) are great for fast and simple automation. The GUI provides many features allowing easy writing, debugging and maintenance of scripts. Such as command and snippet wizards, record & replay, syntax highlighting, breakpoints, step-by-step execution and many more.
  • Java scripts are more flexible. The Java language is very advanced and allows constructions which are not supported by the proprietary scripting language. It is also possible to leverage any functionality delivered by third party Java libraries in the code. Java scripts are fully supported by the T-Plan Robot Enterprise GUI where the code can be compiled and executed on the fly including full syntax checking directly in the native script editor.

Importantly, scripts of both formats can call or run scripts of the other language. This interoperability is great for leveraging the key benefits of each language – tpr for your simple tasks, Java for those more complex. Additionally, tpr scripts can be quickly converted to java scripts using the "export to Java" wizard.

T-Plan Robots Java interface was designed to allow writing of scripts in third party development environments (IDE), such as Eclipse or NetBeans.

To demonstrate the difference between the two scripting languages, below is a simple example of applying some text to the system under automation:

hello.tpr

Hello.java

Type "Hello world!"

import com.tplan.robot.scripting.DefaultJavaTestScript;
import com.tplan.robot.scripting.JavaTestScript; import java.io.IOException;
public class Hello extends DefaultJavaTestScript implementsJavaTestScript {
  public void test() {
        try {
      type("Hello world!");
    } catch(IOException ex) {
      ex.printStackTrace();
    }
  }
}

The example is very simple. The goal is to type the "Hello world" text through a test script into a text editor displayed on the System Under Automation (SUA). 

Instructions:

  1. Move your mouse pointer to the desktop viewer bounds and open a text editor on the SUT. If you are automating on a MS Windows desktop, open Notepad. Linux users may start gedit. Hard core Unix/Linux fans may start vi in a terminal and press 'i' to switch it to the text input mode.
  2. Move your mouse pointer to the script editor on the left. It is necessary to stop the desktop viewer from consuming the keyboard input.
    Then type the following text into the editor: Type "Hello world!"
  3. Select thebutton on the tool bar to execute the typed command. 
  4. The tool should type "Hello world!" into the text editor on the desktop.