OCR Action Operation

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

Description

Use the OCR Action operation to recognize the text content of a UI element on your PC screen or mobile device screen and simulate various user actions over the specified text fragments or next to screen areas. To recognize the text content, the operation uses optical character recognition.

When you add the operation to a keyword test, you specify an area whose text content you want to recognize, the text fragment that identifies the needed part of the area and the method that will simulate user actions.

Requirements

  • Your TestComplete version must be 12.60 or later.

  • You need an active license for the TestComplete Intelligent Quality add-on.

  • The Intelligent Quality add-on must be enabled in TestComplete.

    You can enable the add-on during TestComplete installation. If you did not enable the add-on during the installation, you can do this at any moment later via the File > Install Extensions dialog. To do that, select File > Install Extensions from the TestComplete main menu and enable the Intelligent Quality > Intelligent Quality Core plugin in the resulting dialog.

  • Optical Character Recognition support must be enabled in TestComplete.

    By default, it is enabled automatically if you enable the Intelligent Quality add-on during TestComplete installation. If you experience issues with optical character recognition in your tests, select File > Install Extensions from the TestComplete main menu and make sure the Optical Character Recognition plugin is enabled (you can find it in the Intelligent Quality group). If the plugin is disabled, enable it. In the confirmation message that TestComplete shows when you enable the plugin, click the link to read a third-party license agreement. If you agree to the license terms, click Enable OCR.

    In addition, make sure that you do not have the legacy OCR plugin installed and enabled. You can find the plugin in the Common group.

  • Your computer must have access to the ocr.api.dev.smartbear.com web service. If you have firewalls or proxies running in your network, they should allow your computer to access the web service.

  • Your firewall must allow traffic through port 443.

Operation Result

If the operation recognizes text content of the specified UI element, it returns True. Otherwise, it returns False.

Scripting Analogue

The operation is a keyword test analogue for calling methods of an OCRTextBlock object from script.

Child Operations

The operation cannot have child operations.

Operation Parameters

The operation has the following parameters:

  • The UI element (on-screen object) with which the operation will work.

  • The text fragment by which the operation will detect the area it will simulate user actions on.

  • The text fragment to choose if there are several text fragments that match the text pattern.

  • The method that the operation will call to simulate a user action.

  • The method’s parameters, if any.

When you add the operation to your keyword test, TestComplete shows a wizard that helps you specify these parameters.

To edit parameters of an existing operation in your keyword test, you either double-click the operation to call the wizard, or use in-place editors.

Specify parameters when adding the operation
1. Select Object

On the Select Object page, you specify a UI element (on-screen object) with which the operation will work. You can select the desired object on the screen, or, if the object is mapped, choose the object’s mapped name or alias. For detailed information, see Selecting Objects for Keyword Test Operations.

2. Select Text

The OCR Parameters page shows all the recognized text content of the selected UI element. Select the needed text fragment. It can be either a text fragment on which you want to simulate user actions, or a text fragment located next to the needed screen area (for example, a label next to an edit box).

You can type the text or select it in the recognized text. To specify the text fragment, you can use the (*) and (?) wildcards. The asterisk corresponds to a string of any length (including an empty string); the question mark corresponds to any single character (including none). Whether the text fragment is case-sensitive depends on the Playback > Use case-sensitive parameters property of your project.

If the recognized text does not contain the specified text fragment, an error will occur.

If there are several text fragments that match the text, specify how the operation will choose the needed text fragment:

  • Nearest to center

  • Left most

  • Right most

  • Top most

  • Bottom most

  • Largest

  • Smallest

  • None - The operation will simulate a user action on the first fragment it finds when searching from top to bottom and from left to right, and will then post a warning to the test log.

3. Specify Method

On the Specify Method page, select the user action you want to simulate:

  • You can simulate common actions TestComplete provides for all on-screen objects. You can find their description in the TestComplete Help.

  • To simulate a user action next to the selected text fragment, select one of the following methods:

4. Specify Operation Parameters

On the Operation Parameters page, you can modify the specified text fragment and specify the parameters of the method that the operation will call:

  • For information on parameters of methods common for on-screen objects, see the method description. You can find it by searching for the method name in the TestComplete documentation.

  • For methods that simulate user actions next to the recognized test fragment (ClickNextTo, TouchNextTo, SendKeys):

    1. Specify the relative position of the target area that is next to the selected text fragment.

    2. Specify the distance between the selected text fragment and the target area.

For more information on setting the values on the page, see Specifying Operation Parameters.

Modify Parameters

To modify parameters on an existing operation, you can double-click it in your keyword test. This will invoke the wizard that helps you specify the operation parameters.

You can also use the in-place editors and dialogs:

  1. Select the needed operation in your keyword test.

  2. Click the Value cell twice (not double-click) or select the cell and press F2. This will activate the in-place editor.

  3. Click the ellipsis button of the in-place editor. TestComplete will open the Operation Parameters dialog.

  4. In the dialog, specify the operation parameters. For detailed information on how to work with the dialog, see Specifying Operation Parameters.

  5. Click OK to close the dialog and apply changes.

  6. Press Enter to confirm the changes and close the in-place editor, or press Esc to close the editor discarding any changes.

Remarks

When you add the operation to a test, TestComplete also appends grouping nodes that correspond to the process and window, to which the specified on-screen object belongs.

The operation is available in the AI and Test Actions categories.

See Also

AI Category
Optical Character Recognition
Specifying Operation Parameters
Selecting Objects for Keyword Test Operations
Checking Operation Result

Highlight search results