Image Collections

4.1.1 Image Collections

Image collections typically represent images capturing various visual appearances or possible states of a single graphical object, for example of a button on various environments and/or operating systems. Collections may be employed by the CompareToScreenshot and WaitFor match/mismatch scripting language commands or the corresponding Java methods to locate the component on the screen seamlessly on all environments.

T-Plan Robot Enterprise version 2.0 and higher supports image collections through semicolon-separated image file lists. For example, to search for an "OK" button represented by two template images buttonOK1.png and buttonOK2.png located in the template folder one would use:

Compareto "buttonOK1.png;buttonOK2.png" method=search

T-Plan Robot Enterprise version 2.2 introduces dynamic image collections represented by folders. This mechanism allows adding, remove and edit template images dynamically, without having to update the script code. Each folder is searched recursively for Java supported images of lossless format (PNG, BMP, WBMP, GIF) and the specified image comparison action is performed on the generated image list.

For example, images from the previous example can be moved to a folder called buttonOK and the command can be changed to:

Compareto "buttonOK" method=search

Images retrieved from the folder are by default processed in the natural order returned by the underlying operating system. Version 2.3.3 introduced a new optional mechanism allowing to change this behaviour and sort the images before comparison:

  1. To configure the default sort mode see the CompareTo Command panel in the Preferences window. This setting will be used application wide unless the sort mode is overruled by the script as is described in the next bullet.
  2. Scripts may set the sort mode through the setting of the _COMPARETO_SORT_MODE variable to the desired sort mode index. The variable acts as a switch and the sort mode are applied by all comparison commands until the variable gets reset or the end of the script is reached. Acceptable values are:

0 - Sort by image file name (ascending)
1 - Sort by image file name (descending)
2 - Sort by the image file last modification date (ascending)
3 - Sort by the image file last modification date (descending)

For example, to process the images from the previous example in the file name descending order (buttonOK2.png first) use:

Compareto "buttonOK" method=search

To reset the sort mode to the default one simply set the variable to an empty string:


Image collections can be freely combined into file lists consisting of images and image collections. For example, to search for the "OK" button or an "Approve" button represented by the buttonApprove1.png and buttonApprove2.png images one would use:

Compareto "buttonOK;buttonApprove1.png;buttonApprove2.png" method=search

Or, having created a folder called buttonApprove for the two images one could write:

Compareto "buttonOK;buttonApprove" method=search