Scripting Language Principles

There are just a few basic principles that should be remembered:

  • Each line of code contains a single command
  • A command may consist of:
    • an action – Type, Press, etc
    • a procedure header – using the "Procedure" keyword
    • a procedure call – "<procName> <param>"
    • a comment – using a preceding "#"
  • The language is generally not case sensitive
  • Commands are identified by the following structure "<keyword> <argument> <params>"
  • Command parameters can be present in any order

The user is guided through the scripting principles by the code wizards and properties dialogs which all generate code which automatically enforces this structure.

Example

To demonstrate the scripting language structure let's consider a simple test script example. This one opens the calculator application and calculates the sum of 5+5. Be aware that this is a very simple script which implements neither behaviour verification nor reporting of test result except saving a screen shot.

Note the minor differences between the Windows and Linux scripts - there's really just different calculator application name and the hot key to open the Run box. We will show you in one of the following topics how to separate such system dependent pieces of code in order to create cross platform test scripts.

calculator.tpr (Windows version)calculator.tpr (Linux/Gnome version)
# Generic procedure to start an application on Windows. 
# We take advantage of the Windows+r key to open the Run box. 
procedure startApp { 
  Press Windows+r wait= 3s 
  Typeline "{1}" wait= 4s
} 

# Start calculator, type "5+5" followed by Enter and take a screenshot.
startApp calc 
Typeline "5+5" wait= 2s 
Screenshot calculator_result.jpg desc= "Result of 5+5"
# Generic procedure to start an application on Linux/GNOME. 
# We take advantage of the Alt+F2 key to open the Run box. 
procedure startApp { 
  Press Alt+F2 wait= 3s 
  Typeline "{1}" wait= 4s
} 

# Start calculator, type "5+5" followed by Enter and take a screenshot.
startApp gnome-calculator 
Typeline "5+5" wait= 2s 
Screenshot calculator_result.jpg desc= "Result of 5+5"

 The language is based on the following principles:

  • Test scripts are plain text files. Each line may contain a command (Press, Typeline, Screenshot, ...), a procedure header (starting with the "procedure" keyword), procedure call ("startApp <param>") or a comment (starting with "#"). Though it is not seen in the example, the line may also contain an if/else or for statement. 
  • Commands are identified by the first word (in blue) which is usually (but not always) followed by an argument (in green) and a list of parameters (in bold black) in form of '<param>="<value>"'
  • The language is not case sensitive except a few cases described explicitly in the specification. Commands and their parameters may be specified in any combination of upper or lower case characters. The procedure name "startApp" in our example however is case sensitive.