About OCR Checkpoints

Applies to TestComplete 15.63, last modified on April 23, 2024

An OCR checkpoint is a test operation that recognizes text content of a UI element using optical character recognition and verifies that the recognized text matches the specified pattern.

This can be helpful when testing applications, the internal properties of which TestComplete cannot access, for example, if TestComplete does not support your application type or if the needed controls are graphical objects rendered on the screen.

In keyword tests, OCR checkpoints are performed using the OCR Checkpoint operation:

OCR checkpoint in a keyword test

In scripts, OCR checkpoints are performed using the OCR.Recognize(SearchArea).CheckText method:

JavaScript, JScript

OCR.Recognize(Aliases.Orders.MainForm.OrdersView).CheckText("*Mark?Twain*");

Python

OCR.Recognize(Aliases.Orders.MainForm.OrdersView).CheckText("*Mark?Twain*")

VBScript

Call OCR.Recognize(Aliases.Orders.MainForm.OrdersView).CheckText("*Mark?Twain*")

DelphiScript

OCR.Recognize(Aliases.Orders.MainForm.OrdersView).CheckText('Mark?Twain*');

C++Script, C#Script

OCR["Recognize"](Aliases["Orders"]["MainForm"]["OrdersView"])["CheckText"]("*Mark?Twain*");

How an OCR Checkpoint Works

During the test run, TestComplete:

  1. Gets the UI element, the text content of which you want to verify.

  2. Recognizes text contents of the UI element using optical character recognition.

  3. Checks whether the recognized text matches the expected value and reports the results.

How to Create OCR Checkpoint

You can add OCR checkpoints to your test during the test recording and at design time using the Create Checkpoint wizard. For detailed instructions, see Creating OCR Checkpoints.

OCR Checkpoint Results

If the recognized text content matches the expected value, the checkpoint logs the checkpoint passed message; otherwise, it logs the error message. The Details panel of the test log shows the sought-for text and the actually recognized text.

Alternatives to OCR Checkpoints

  • If TestComplete can access internal properties of the needed UI element, use a property checkpoint to verify its text contents.

  • If your tested application implements accessibility information using the Microsoft Active Accessibility (MSAA) engine or the Microsoft UI Automation framework, you can configure TestComplete to use that accessibility information to get the content of the needed controls and use a property checkpoint to verify it.

  • (For Windows desktop applications only) If your tested application uses the WM_PAINT, WM_PRINTCLIENT, or Direct2D library to render its text content on the screen, you can use Text Recognition to access the rendered text and the property checkpoints to verify it.

  • If TestComplete cannot recognize the text content of your tested object properly or to verify how your tested application’s user interface looks on the screen, you can use a region checkpoint.

See Also

OCR Checkpoints
Optical Character Recognition
OCR Checkpoint Operation

Highlight search results