Image Templates
Before jumping into writing scripts and using the various scripting wizards etc, it is important to understand the best practises of image based automation and in particular the creation and use of image templates.
Although T-Plan Robot supports other recognition methods (text, colour, etc) it is predominantly used for its advanced image comparison capability. Naturally at the heart of this are two key endpoints – the image template(s) and the screen image of the connected environment.
In order for an image comparison to complete successfully Robot must obviously match the two, within the defined boundaries and tolerances.
To attain the best possible success rates, and therefore inherently improve reliability of your script executions, there are three important factors to consider:
- Obtaining the 'best' image templates
- The use of "Image Collections"
- The use of the search parameters
With regards to the image templates, the general rule of thumb is to keep them as small as possible, while remaining unique. Remember, an image template does not always necessarily need to make sense to the human eye.
When a comparison is performed, it is so against the entire image template. Once the results have been returned Robot then applies the tolerance parameters (passrate, etc) and determines whether it should be deemed as a success or a failure. Due to this it is important to get your templates right.
Taking a very simple example, of the desktop Calculator application:
In order to verify that the application is running, we may choose to search for a part of the screen that will remain fairly static, such as the menu bar.
The following is an example of a poor image template:
At first sight there may not seem too much wrong with this template, however there are many things that at a programmatic level could cause a comparison to fail. This is therefore deemed 'poor' due to the following characteristics:
- It includes background
- It includes the window icon and Title
- It includes part of a button in the top right
- It includes three separate words
- It includes part of the main Calculator window
- It consists of many different colours
If the purpose of the image search is to verify that a button appears as it should, or that the icon is correct then obviously your image template should rightly include all of that, however, if it is merely a means of verifying a previous action has been applied then you may be able to really narrow down the template selection, such as:
Notice how this template now doesn't include any such background 'noise', nor does it include window borders, other screen components nor the text shortcut underline. All of this drastically reduces the potiential for the image comparison to fail should there be any unexpected slight differences, thus increasing success rate which in turn increases reliability.
In addition, the smaller the image template the quicker Robot will be able to perform the comparison. When you are dealing with potentially hundreds of image comparisons over the course of a script execution even time savings of seconds can add up very quickly thus also making your scripts much more efficient.
All image templates are stored within the "Component Images" branch of the Project tree. From there the templates can be used, modified or deleted.