You are here: Chapter 3: Introduction to Test Scripts > Scripting Overview

Scripting Overview

 T-Plan Robot is in fact a scriptable desktop viewer which follows instructions from a test script to reproduce user actions on the desktop. Test scripts may be of three formats:

It is important to realize that both test 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). That is why you should use the language specification as a reference even if you decide to develop your test suite or its part in Java.

The following example shows the "Hello world" code example with a corresponding test script in Java.

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();     }   } }

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:

 

12 December 2014

Copyright © T-Plan Ltd.

Version 1.0