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:
In scripts, OCR checkpoints are performed using the OCR.Recognize(SearchArea).CheckText
method:
JavaScript, JScript
Python
OCR.Recognize(Aliases.Orders.MainForm.OrdersView).CheckText("*Mark?Twain*")
VBScript
DelphiScript
C++Script, C#Script
How an OCR Checkpoint Works
During the test run, TestComplete:
-
Gets the UI element, the text content of which you want to verify.
-
Recognizes text contents of the UI element using optical character recognition.
-
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
, orDirect2D
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