This topic explains how to diagnose and resolve the “Unable to recognize the image of the current desktop” error that occurs when the test engine fails to find an image on screen during the test run.
|
If you get this error message when running an image-based test recorded with TestComplete version 10.20 or earlier on an Android device emulator or on an Android virtual machine, read the sections below. |
About the Error Message
To interact with black-box applications, TestComplete can use images of objects displayed on the screen.
-
You capture images of the tested controls and save them to the Image Repository.
Note: |
For Android applications, TestComplete can capture images and store them to the repository automatically during test recording. |
-
You create tests that identify the needed controls by their captured images and simulate user actions over the controls.
-
During the test run, TestComplete searches for image on the screen. If the image is found, TestComplete simulates the user action over the control. If TestComplete fails to find the image, it posts an error message to the test log.
This message indicates that something has changed either in the tested application and its state differs from the state it had when you captured the image.
See the sections below to learn how you can find the cause of the problem and fix it.
Diagnosing the Problem
-
Explore the test log and find the “Unable to recognize the image on the current desktop” error.
-
Select the error message in the log and switch to the Additional Info panel in the Test Log panel.
-
In the Additional Info panel, click the ImageRepository.ImageSet_Name.Item_Name link to open and explore the image in the Image Set editor.
-
In the Picture panel of the log, examine the image of your screen captured during the test run and check whether the needed control is present on screen.
As an alternative, examine your actual screen and check whether the needed control is present on it.
For mobile devices, to explore the tested application and search for the problematic image, you need to connect the mobile device under test to the computer.
Your tested application must be running. If the application was closed after the test was over, run it again and pause the run on the problematic test command:
-
Set a breakpoint on the command that caused the error.
Double-click the error message in the test log. TestComplete will open the test for editing and highlight the command that was being executed when the error occurred.
To set a breakpoint, click the editor’s gutter next to the command or press F9. After the breakpoint is set, the line will be highlighted in red.
-
Run your test. The test engine will automatically pause the test run when it reaches the breakpoint.
-
If the control is not on the screen (for instance, the developers could remove the control from it), than you need to update your test to address the changes in the application.
If the object is present on the device screen, but TestComplete fails to find it, than to find the cause if the error, perform the step below.
-
Check the screen resolution, orientation, color scheme, brightness and other visual settings.
Controls in applications may look different depending on the screen resolution, orientation, color scheme and so on. If TestComplete fails to find an object because the visual representation of the application under test has changed, you need to add images for all possible control representations to the image collection. To learn how to do this, see The screen resolution, orientation or color scheme has changed section below.
Possible Causes of the Problem
Below are typical causes of the problem and typical ways to eliminate them.
The object is not present on the screen.
The object is not present on the screen.The object is not present on the screen.Check whether the object is on the screen. The most possible cause of the problem is that the developers have removed the control. The general solution is to change your test in order for it to address the changes in the application.
The object has not appeared on the screen by the time TestComplete tries to find it.
The object has not appeared on the screen by the time TestComplete tries to find it.The object has not appeared on the screen by the time TestComplete tries to find it.It is possible that the object has not appeared on the screen by the time the test engine starts searching for the object’s image on the screen. To solve the problem, you can modify your test so that it waits for the object to appear on the screen. For detailed instructions on how to do this, see Waiting for Objects in Image-Based Tests.
The screen resolution, orientation or color scheme has changed.
The screen resolution, orientation or color scheme has changed.The screen resolution, orientation or color scheme has changed.Controls may look different depending on the screen resolution, screen orientation or color scheme set on the device. To allow the test engine to find the desired object regardless of the visual representation of the screen, you can add all possible images of each control to the appropriate image collection of the image set.
You can do this directly from the test log:
-
In the Additional Info panel of the error message, click Add:
Click the image to enlarge it.
-
TestComplete will open the problematic image item in the Image Set editor and call the Add Image to Image Repository wizard.
-
Follow the wizard instructions to add the image captured during the test run as a variation of the problematic image item. You can then view it in the Image Strip panel of the Image Set editor:
Click the image to enlarge it.
You are running a test for an Android device emulator or virtual machine recorded with an earlier version of TestComplete.
You are running a test for an Android device emulator or virtual machine recorded with an earlier version of TestComplete.You are running a test for an Android device emulator or virtual machine recorded with an earlier version of TestComplete.In TestComplete 10.20 and earlier, the image capturing mechanism used for image-based tests worked incorrectly. The colors of images captured on Android device emulators and Android virtual machines were distorted. Since version 10.30, TestComplete uses a new image capturing mechanism that works correctly.
If your image-based tests recorded with a previous version of TestComplete still use images with distorted colors, these images will not be recognized when you run the tests in a newer version of TestComplete. If you experience any image recognition issues when running image-based tests recorded with a previous version of TestComplete, consider doing the following:
-
(Recommended) Move from image-based tests to object based (white-box) tests. Object based tests use internal object properties for object identification and are not affected by changes in graphical representation of the application under test.
-
Adjust the Color tolerance parameter of the images used in your tests:
-
Open the desired image set in the Image Set editor.
-
Select the desired items in the Items list of the Image Set editor or select the desired images in the Image Strip panel of the editor. Use CTRL-click and SHIFT-clicks for multi-selection.
-
Right-click the selection and choose Set Recognition Parameters from the context menu.
-
In the subsequent Set Recognition Parameters dialog, specify the desired value for the Color tolerance recognition parameter. We recommend that you set the color tolerance parameter to eight or a higher value.
-
Re-capture the images used in your image-based tests. To do this, run the application under test and add new images for the desired controls to the Image Strip in the Image Set editor. For more information on how to do this, see Adding Images to the Image Strip.
-
Re-record your image-based tests.
See Also
Handling Playback Errors
Image-Based Testing
Working With Image Set Editor