TestComplete 8 Sneak Peek: Image Comparison Enhancements
Recent versions of the Microsoft OS - Windows Vista, Windows Server 2008 and Windows 7 – introduced the Aero graphical user interface. It boasts a superior design enhanced by subtle effects such as translucency, image overlaying, dynamic reflections and smooth animations.
The "glass" design is undoubtedly a pleasure to the eye, but at the same time the Aero effects bring additional difficulties to software developers and QA departments. For instance, the translucency affects the comparison of an application’s windows because due to the window’s semi-transparency, it includes the regions where the underlying windows or the background is seen. As a result, the ordinary pixel-to-pixel comparison does no good.
Here is an example. The two pictures below show the same fragment of a dialog taken over different backgrounds. The third picture illustrates the difference between them according to the pixel-to-pixel comparison algorithm:
|Image1 ||Image2 |
| || |
|Image Difference |
To resolve this and other “Aero troubles” our developers enhanced the image comparison engine and introduced a couple of new parameters that would make the comparison smarter.
Alpha Channel Support
In addition to the color for each pixel, BMP, PNG and TIFF images may also contain information that denotes pixels' transparency - the so called alpha channel. Depending on the alpha value, a pixel may range from fully transparent (0%), through semi-transparent to fully opaque (100%).
TestComplete now supports images containing alpha channel and performs the comparison and search operations taking the pixel’s alpha value into account. Fully transparent pixels are ignored during the comparison, opaque pixels should have exactly the same color to be reported as matching, and the colors of semi-transparent pixels should resemble one another to some degree (the degree of conformity is determined by the alpha value).
For instance, the first image below contains the alpha channel. When it is compared against the second image, TestComplete considers the two images to be identical:
|Image1 ||Image2 |
| || |
Color tolerance (ColorTolerance) is a new parameter of the comparison engine. It allows you to ignore certain differences between the colors of compared pixels. By assigning an appropriate value to this parameter, you can compare UI elements whose color is different - windows and controls captured in different UI themes, skins, color schemes and others.
For example, the two images below display the same button whose image was taken in various color schemes. If they are compared without additional parameters, they will definitely be reported as unequal.
|Image1 ||Image2 ||Image Difference |
A button captured in the Blue Windows XP scheme.
A button captured in the Silver Windows XP scheme.
However, comparing them with the ColorTolerance parameter set to 50 makes TestComplete consider these images as equal.
This parameter defines which areas of the images should be compared, and which areas should be ignored. The comparison mask is another image that holds only black-and-white pixels. White pixels on the mask are taken into account during comparison, whereas black pixels are ignored.
For instance, the comparison mask given below, excludes semi-transparent areas of the Vista Open dialog from the comparison. Once such a mask is passed to the TestComplete comparison engine, it would only compare the dialog’s central portion.
|Comparison Mask ||Dialog ||Compared Area |
| || || |
We hope these new features will help you implement more flexible comparison procedures and create more powerful tests. You can check them in TestComplete 8 Beta. If you have not joined the beta testing yet, apply for the Beta today.