Handling the 'Object Does Not Exist' Error

Applies to TestComplete 15.47, last modified on January 20, 2023

About the error message

TestComplete considers processes, windows, and controls as objects. Before running a test command on some object, TestComplete first finds this object in the system. To do this, it uses the recognition criteria set for the object in the Name Mapping repository. If the recognition criteria match completely and the object is found, TestComplete executes the test command on it.

If applicable, TestComplete will try to find an object similar to the missing one. Depending on whether the self-healing mode is enabled, it either uses the replacement object to continue the test run or posts information on the replacement object to the test log. Otherwise, it will post the error message to the test log.

The “Object Does Not Exist” message indicates that the tested application differs from the state it had during test recording or test creation. For example, earlier test steps have failed and the needed window or control didn’t appear on the screen, the parent object of the target object didn’t exist, the recognition attributes of the object changed, and so on (see the possible reasons below).

Explore the problem

1. Explore the test log

  1. Find the first “The … object does not exist” error in the test log. Depending on the executed command, TestComplete can post several error messages to the log. Typically, the very first message corresponds to the root cause of the problem and further errors are caused by this error.

    Consequent error messages in the test log
  2. Select the error message in the log and explore the details on the Details and Picture tabs:

    Detailed information on error in the test log's Details and Picture tabs

    Click the image to enlarge it.

    Note: The Picture tab contains an image only if the Post image on error project setting was enabled during the test run. By default, the setting is enabled.

Tips:

  • Quite often, the missing object is not the object whose method or property you called. It may be some of its parent objects. For example, the “ClickButton” command fails if the window that has the needed button was not found in the system. So, read the error message on the Details tab to understand what object caused the problem.

  • One of the possible reasons why the search fails is that the recognition attributes of the needed object have changed. To help you solve this problem, TestComplete automatically searches for objects that are similar to the missing object.

    If a similar object is found, TestComplete will suggest updating the recognition attributes to use the found object in subsequent test runs:

    Click Apply Intelligent Fix to update recognition attributes

    Click the image to enlarge it.

  • To better understand what test command was being executed when the error occurred, double-click the error message in the test log. TestComplete will open the test editor and will highlight the line that was being executed when the error occurred.

2. Explore the tested application

  1. The tested application must be running and have the same state it had when the error occurred. If the application was closed after the test run, you can start it again and pause the run on the problematic test line. To do this:

    1. Set a breakpoint on the problematic line in the script test or keyword test operation. To find that line or operation quickly, double-click the error message in the test log. TestComplete will switch to the test editor and highlight the line or operation that caused the error. To set the breakpoint, click the editor’s gutter next to the line or operation, or press F9.

    2. Run your test. The test engine will automatically pause the test run when it reaches the breakpoint.

  2. Examine your application and check whether the desired object exists. For instance, developers could change the tested application and remove the tested form or button from it. This change could cause an error in your test.

    See instructions for web tests running in remote environments

    See instructions for desktop, mobile tests, and web tests that run on your local computer

    If the object does not exist in the application, re-record your test or update its commands to match the tested application.

    If the object exists, then, to find the cause of the error, explore properties of the problematic object:

    1. In TestComplete, select Display Object Spy from the Tools toolbar. This will open the Object Spy.

    2. Use the Object Spy to select the needed object on the screen:

      • You typically select a window or control by dragging the target icon () to it. See how it works.

      • If you need to select a hint, menu item or another popup object, use the “Point and fix” mode. See how it works.

      After you select the object, the Object Spy will display its properties.

One more tip: By default, the test engine logs images of the tested application for every simulated test command to help you understand what happened in the application during the test run. You can find these images on the Picture tab of the test log. A possible alternative is to record a video of your test run. See the description of the VideoRecorder extension for information on how to do this.

Possible causes of the problem

Below are typical causes of the problem and typical ways to eliminate them.

Most possible causes

The object didn’t exist at the time TestComplete tried to obtain it.

The object’s recognition criteria changed. (Applicable to desktop and web tests)

The object’s position in the object tree was changed.

One of the parent objects causes the ambiguous recognition problem.

Other possible cases

The tested process was not found.

The alias refers to a mapped object that is not in the NameMapping project item.

The tested application stopped responding.

The object tree model differs from the model that was used to create the test.

Video

To learn how TestComplete locates objects in tested applications, why it may fail to find the objects, and how to handle this, you can also take a video course in our SmartBear Academy:

smartbear.com/academy/testcomplete/testcomplete-handling-the-object-not-found-errors

See Also

Other "Object Not Found" Errors
Name Mapping
Object Browser Naming Notation
About Object Browser

Highlight search results