Tips & tricks - OCR methods (Windows only)

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. Therefore, keep the guidelines below in mind when using these methods.

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 the operating system, installed service packs, installed toolkits, and so on, 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: