While testing, you may need to verify that an object or area of the application under test is present on the screen or that it is displayed correctly. You do this by using region checkpoints or Image Repository or other operations and scripting methods for image comparison. The comparison engine performs pixel-by-pixel comparison when verifying images.
Sometimes, image comparison may fail when the content of the compared images seems to be identical and when you do not expect a failure. Such failures may be caused by different factors that affect image comparison.
This topic provides information on the most probable reasons of image comparison failures and lists possible solutions you can use to make verification pass successfully.
If image comparison failed, pay attention to where the mouse pointer was located before the image to be compared was captured.
By default, the mouse pointer is not captured by the comparison engine. However, hovering of the mouse pointer over the object to be captured may change the object’s visual appearance and the captured image of this object will not match the baseline image.
For instance, hovering of the mouse pointer may cause highlighting of a certain control and changing its color, some gradients may appear around the object, and so on. As a result, this will cause an image comparison failure.
Image comparison failures may also be caused by font smoothing used in the captured object. If one of the compared images contains smoothed text while the other image contains a non-smoothed version of the same text, then comparison of such images will fail.
Font smoothing should be either enabled or disabled when both the baseline and actual images are captured. See also the Ignoring a slight difference between images section of the Comparing and Finding Images - Specific Tasks topic for information on how you can solve this problem.
User Interface Visual Themes
Another important factor that affects image comparison is the user interface theme used in Windows when images are captured.
The Aero theme of the Windows user interface causes certain difficulties during image comparison. This UI theme uses translucency in application windows. Therefore, the background, on which the window is captured, may be visible through the window. This affects image comparison greatly, since images of the same window captured on different backgrounds differ from each other and this causes image comparison failures.
For information on how you can solve this problem, see Comparing and Finding Images When the Aero Theme Is Active.
Rounded Window Corners in Windows XP Theme
The Windows XP user interface theme also causes difficulties during image comparison.
Window headers in this UI theme have rounded corners, whereas the captured image has a rectangular form. Therefore, when you capture such a window, the screenshot’s upper corners contain parts of the underlying windows or background. If the baseline image and the compared one were captured on different backgrounds, the comparison of these images will fail.
See the Rounded Window Corners in Windows XP Theme section in the Factors Affecting Image Comparison topic to learn how you can solve this problem.
Images is in JPG Format
The comparison of images saved in JPG leads to an inaccuracy in comparison results. The JPG format uses low compression methods which may cause similar-looking pixels to have a different color and opacity ratio. Also, similar JPG images with different compression levels will be recognized as not identical due to the features of the JPG format. Use other formats to ensure the accuracy of comparison results.
If image comparison failed and the regions are slightly different, you can adjust the pixel tolerance and color tolerance recognition parameters. For region checkpoints, if the image comparison fails, TestComplete will calculate the recognition parameters to treat the images as equal and show them in the Details panel of the test log.
In addition, you can update stored images after the image comparison fails. To do this, use the Update the <Checkpoint_Name> checkpoint data link or the Add an image from the current screen to the <Image_Repository_Item> link in the Details panel after the test is over.
For more information on other factors that affect image comparison and may cause comparison failures, see the Factors Affecting Image Comparison topic.