Handling the 'The text was not found' Error

Applies to TestComplete 15.42, last modified on September 08, 2022

About the Error Message

You can use optical character recognition to capture the text rendered by your tested application on screen, and then locate the screen area containing the needed text to simulate user actions on it.

During the test run, TestComplete recognizes the whole text the specified area renders, and searches for the needed text fragment. If it finds the text, it simulates the specified user actions over the appropriate screen area. If it fails to find the text, it posts the “The text was not found” error message to the test log.

This message indicates that something has changed in your tested application, and the text it is rendering differs from the text it was rendering during test recording or when you added the operation to the test.

1. Diagnosing the Problem

  1. In the test log, find the “The text was not found” error. It shows the text fragment TestComplete couldn't find.

  2. Switch to the Details panel of the error message. It shows the text the test engine recognized in the search area:

    Detailed information on the error in the Details panel of the message

    Click the image to enlarge it.

  3. Examine the full text and make sure the needed fragment is present in it.

  4. If the needed text fragment is not present in the recognized text, explore the application as described below.

2. Explore the Application

  • The tested application must be running and must 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:

    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 and highlight the line or operation that caused the error. To set a breakpoint, click the editor gutter next to the line or operation, or press F9.

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

  • Look at your application and check whether the needed text is present on screen. For instance, the developers could remove the text from the tested application or change it. This could cause the error in your test.

  • If the needed text fragment is present, but the test engine cannot recognize it correctly, do the following:

    1. Check whether the needed text contains any variable parts that change from one test run to another, which does not allow TestComplete to recognize them. Use the asterisk ( * ) or the question mark ( ? ) wildcard. The asterisk corresponds to a string of any length (including an empty string), the question mark corresponds to any single character (including none).

    2. Make sure your tested application’s graphical representation does not disrupt the text recognition. For example, some font styles or sizes, or the background on which the text is rendered may affect the text recognition accuracy.

Possible Causes of the Problem

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

The text is not present on screen

The application's graphical representation makes character recognition unreliable

See Also

Optical Character Recognition
Optical Character Recognition - Troubleshooting
Possible Alternatives to Optical Character Recognition

Highlight search results