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

Image comparison capabilities

As T-Plan Robot works on the desktop image level, image comparison is one of the key means of verifying behavior of the tested application. The idea is that during test script design you save image templates of the tested application or its components for a reference. When the script is executed, the desktop image is compared to the template(s) to verify that it displays the expected result.

Version 2.2 supports four image comparison algorithms, tolerant image search, object search, Tesseract OCR and the legacy histogram based comparison method. All four methods will be discussed later on in separate topics with examples provided. As support of image comparison in T-Plan Robot Enterprise is an open framework, anyone is welcome to plug in third party algorithms and make them available to test scripts.

Image comparison may be invoked through one of the three script commands (or their corresponding methods in the Java Test Script API):
  • Compareto - Compare a template image or images to the remote desktop.
  • Screenshot - Save screen shot of the remote desktop to a file and optionally compare it to a template image or images.
  • WaitFor match/mismatch - Pause the execution until ('match') or while ('mismatch') the remote desktop matches to a template image or images.
All commands accept the same set of image comparison parameters. T-Plan Robot Enterprise up to version 2.1 supports templates specified as a single image or a semicolon separated list of images. Version 2.2 introduces additional support of dynamic image collections represented by folders. As the test script refers to the collection by a simple folder name, this mechanism allows to add, remove and edit template images inside the image folder without having to update the test script code. When the script is executed, each collection is searched recursively for Java supported images of losless format (PNG, BMP, WBMP, GIF) and the specified image comparison action is performed on the generated image list. Image collections may be of course freely combined into the old style semicolon separated file lists with single images or other image collections. See the image collection specification for examples.

Version 2.2 also creates image meta data for each newly created or updated template image. The meta data file for example contains the original template image location on the screen which allows the test scripts to test whether the component has moved or not. Meta data also defines the best click point for the eventual "find and click" type of tasks. The click point defaults to the image center and may be customized in the GUI. For more informtaion see the image meta data specification.

The comparison is considered to pass when at least one template from the list produces a match. This allows one graphical object to be represented by multiple images, for example where one script is being executed against various environments (operating systems) or when the verified component is known to changes its state (appearance).

Default location of template images in the file system is defined by the _TEMPLATE_PATH variable and defaults to the user home folder (configurable in the Preferences->Scripting->Language window). All template images and collections specified in a relative way will be resolved against this directory. To set the folder to a custom location simply set the variable at the beginning of your script using the Var command. A favorite trick is to put images into the same folder as the test script and set the template path to this location as follows. This allows to create a relocatable test suite which is independent from any fixed file paths:

There are CompareTo, Screenshot of WaitFor windows allowing to construct and maintain the commands easily as well as create and edit the template image(s). Images and commands may be also comfortably generated through the Component Capture feature. For full specification of individual parameters refer either to the window help or to the CompareTo command specification.

The following picture demonstrates the GUI representation of image comparison parameters and their corresponding script commands on an example of image collection with two template images of a button in enabled and disabled state.

TIP: To learn more about image comparison principles read the Image Comparison With T-Plan Robot Enterprise 2.0 help topic.