Update Selectors for Web Objects

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

To simulate user actions over elements in a web application or on a web page, TestComplete locates the elements by using XPath expressions and CSS selectors. It stores these expressions and selectors in the Name Mapping repository of your TestComplete project.

If your tested application or web page has been modified or updated (for example, if a new version has been released), its elements may change their position in the DOM hierarchy, or their ID, class, or caption can change. The stored selectors will no longer remain valid and TestComplete will not be able to identify the web elements on the page correctly.

You can update the selectors to match the actual state of the object:

Automatically, by using Intelligent Fix

When applicable

For TestComplete to be able to update selectors automatically, the following requirements must be met:

  • TestComplete version 15.20 or later.

  • An active license for the TestComplete Intelligent Quality add-on.

  • The Intelligent Quality add-on must be enabled in TestComplete.

    You can enable the add-on during the TestComplete installation. If you did not enable the add-on during the installation, you can do this at any moment later via the File > Install Extensions dialog.

  • Optical Character Recognition support and Self-Healing Tests support must be enabled in TestComplete.

    If you experience issues with self-healing tests support in your tests, select File > Install Extensions from the TestComplete main menu and make sure these plugins are enabled (you can find them in the Intelligent Quality group). If any of the plugins is disabled, enable it.

  • Your computer must have access to the ocr.api.dev.smartbear.com web service.

    If you have firewalls or proxies running in your network, they should allow your computer to access the web service. This web service is used to search for a replacement object by the text contents of the missing control image.

  • Your firewall must allow traffic through port 443.

  • Your test must use mapped objects.

  • The Name Mapping repository of your project must store the images of the mapped objects.

How automatic updates are applied

If self-healing is applicable, when TestComplete fails to find an object during the test run, it will try to resolve the issue automatically by finding a similar object:

  1. TestComplete will check whether the object’s identifier, class name, and other attributes used by selectors have been changed and search for similar objects.

  2. Among all similar objects that TestComplete finds, it will select the one closest to the missing object by comparing them to the missing object’s screenshot that the Name Mapping repository stores (if any).

Depending on the Enable Self-Healing mode option, TestComplete will either use the found object to proceed the test run or report the “The Object Does Not Exist” error. In any case, after the test run is over, it will suggest that you update the object’s recognition criteria to match the found object:

Updating Name Mapping by using Intelligent Fix

Click the image to enlarge it.

In the test log, examine the suggested recognition criteria changes. If needed, examine the image of the found object to make sure that it is the right one.

Apply the suggested changes.

Manually

Prerequisites

  • Launch one of the supported web browsers and navigate to the tested web application or a web page.

  • Make sure that the object whose selectors you want to update is present on the web page.

From the Name Mapping repository

  1. Open the Name Mapping repository of your project in TestComplete.

  2. Locate the object whose selectors you want to update.

  3. Click Update Selectors on the repository toolbar or right-click the object in the Mapped Objects tree and then click Update selectors.

  1. TestComplete will open the Update Selectors from Object dialog.

  2. Using the or tools that the dialog provides, point to the target object in the web browser.

  3. Click OK. TestComplete will generate selectors for the object you have pointed to and replace the stored selectors with the new ones.

Updating selectors from the Name Mapping editor

Click the image to enlarge it.

From the test log

If a web object’s selectors are no longer valid, TestComplete will not be able to find the object during the test run and report the “The object does not exist” error:

  1. Select the error message in the test log.

  2. Explore the Picture panel and the Details panel. Make sure that the problematic web object existed during the test run.

  3. Click the Update the search criteria link in the Details panel

  1. TestComplete will open the Update Selectors from Object dialog.

  2. Using the or tools that the dialog provides, point to the target object in the web browser.

  3. Click OK. TestComplete will generate selectors for the object you have pointed to and replace the stored selectors with the new ones.

Updating selectors from the test log

Click the image to enlarge it.

See Also

Update Name Mapping
About Cross-Platform Web Tests
Handling the 'Object Does Not Exist' Error

Highlight search results