Possible Alternatives to Optical Character Recognition

Applies to TestComplete 15.64, last modified on June 12, 2024

Usually, you use optical character recognition (OCR) to get the text contents of your tested application when you cannot access it by using the application’s internal objects. However, there can be situations when you cannot use optical character recognition in your tests. For example, if your computer does not have access to the recognition web service for security reasons, or if optical character recognition does not recognize the text properly. Also, there can be a situation when your tested UI elements do not contain any text at all.

In these cases, you can use one of the following alternative approaches:

  • Text recognition (For Windows Desktop applications only) - TestComplete can track Windows function calls that render text on the screen. You can configure TestComplete to track such calls to recognize individual controls by their rendered text. This approach works faster and is more accurate than optical character recognition. See Using Text Recognition Technology.

  • Region checkpoints and image-based tests - If optical character recognition in TestComplete cannot recognize the text content of your tested application accurately enough or if no text content is available at all, you can identify your tested UI elements by their images. See Image-Based Testing.

    To check how your application looks on the screen, you can use region checkpoints.

  • Accessibility information - If your tested application implements accessibility information using Microsoft Active Accessibility (MSAA) or UI Automation, you can configure TestComplete to use that information to access your application’s internal properties. You will be able to identify individual windows and controls by their accessibility information and get their contents. See Using Microsoft Active Accessibility and see Using Microsoft UI Automation Technology.

  • Use coordinate-based user actions - If optical character recognition does not recognize the needed text reliably enough, you can use coordinates to simulate user actions in your tested applications. For instance, you can simulate user actions on a tested control based on its coordinates in your tested application or on its coordinates on screen. For example:

    Sys.Process("MyApp").Window("MainWindow", "*").Click (256, 10)
    Sys.Desktop.Click(512, 764)

    To record coordinate-based user actions, in TestComplete, disable the Tools > Options > Engines > Recording > Record unsupported controls using OCR option.

    To add coordinate-based commands to your tests manually:

    • In keyword tests, use the On-Screen Action operation.

    • In scripts, use the methods TestComplete provides for all onscreen tested objects. For these methods, you can specify the coordinates where the appropriate action is to be simulated. To learn more, see the methods' descriptions.

    Simulating user actions based on coordinates is not reliable. We recommend that you use other approaches to test your applications.

See Also

Optical Character Recognition
Using Text Recognition Technology
Image-Based Testing
Using Microsoft Active Accessibility
Using Microsoft UI Automation Technology

Highlight search results