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

Scripting Language Principles

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:

 

12 December 2014

Copyright © T-Plan Ltd.

Version 1.0