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.
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.
If the operation recognizes text content of the specified UI element, it returns True. Otherwise, it returns False.
The operation is a keyword test analogue for calling methods of an
OCRTextBlock object from script.
The operation cannot have child operations.
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.
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.
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
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.
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 (see Searching for Information).
To simulate a user action next to the selected text fragment, select one of the following methods:
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 Help (see Searching for Information).
Specify the relative position of the target area that is next to the selected text fragment.
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.
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:
Select the needed operation in your keyword test.
Click the Value cell twice (not double-click) or select the cell and press F2. This will activate the in-place editor.
Click the ellipsis button of the in-place editor. TestComplete will open the Operation Parameters dialog.
In the dialog, specify the operation parameters. For detailed information on how to work with the dialog, see Specifying Operation Parameters.
Click OK to close the dialog and apply changes.
Press Enter to confirm the changes and close the in-place editor, or press Esc to close the editor discarding any changes.
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.