Tips & tricks - OCR methods (Windows only)

The following tips and tricks are relevant when identifying text in your application.

UFT Developer 2021 R1 and later: To use OCR methods, the ABBYY OCR engine has to be included in the UFT Developer installation.

UFT Developer methods that use OCR

Capture visible text from within a specific object in your application using the GetVisibleText and GetTextLocations methods, available for all test objects.

You can also capture an image of any part of your application and then use the GetText and LocateText methods of the ImageUtils class to capture text from within a supplied image.

These methods use an OCR (optical character recognition) mechanism to capture text. Follow the guidelines below to optimize your results.

Back to top

Getting an object's text

For test objects that support it, get an object's text using the text property (C#) or getText method (Java) or similar.

These programmatically retrieve the object's text.

Use the OCR methods only when these methods of retrieving text are not available.

Back to top

Using OCR methods

When using OCR methods, results are best for standard fonts with a letter size of at least 10pt, and with high contrast (black letters on white background works best).

Back to top

Specifying text area in OCR methods

When specifying the text area in OCR methods, try to keep the dimensions of the rectangle as small as possible. This helps prevent unwanted characters in captured text.

However, keep in mind that conditions such as operating system, installed service packs, or installed toolkits, can affect the size and location of an object in an application. Make sure that the dimensions of the selected text area are large enough to account for different system configurations.

Back to top

Windows themes

Set your Windows theme to use a well-contrasted color schema and without color gradients.

Back to top

See also: