In TestComplete, you can use optical character recognition to find a screen area by the text it shows and simulate user actions on that area (for example, click it).
In keyword tests
Use the OCR Action operation to simulate user actions on the screen area that contains the needed text:
-
Add the operation to your test.
-
Select the onscreen object on which you want to simulate user actions. TestComplete will recognize all the text in that object.
The selected object must exist in your system and must be visible on screen.
Note: To specify an object in a mobile application, you can select it in the Mobile Screen window. Both the application under test, and the mobile device where the application is running must be prepared for testing in order for TestComplete to be able to access them.
To get the entire screen of your mobile device, you can use theMobile.Device.Desktop
property. -
Select the text fragment on which you want to simulate user actions. If there are several fragments that contain text, specify the one you need.
-
Select the method you want to use to simulate user actions.
-
Specify method parameters, if needed.
In scripts
To simulate a user action on a screen area that contains the needed text, call the appropriate method of the OCR.Recognize.Block
or the OCR.Recognize.BlockByText
objects. For example:
JavaScript, JScript
Python
VBScript
DelphiScript
C#Script
Supported user actions
On on-screen areas that TestComplete recognizes by their text contents, you can simulate the following user actions:
In Desktop and Web Applications
-
Clicks and double-clicks:
By default, these methods simulate clicks at the center of the specified screen area. To simulate clicks at a specific point of the area, call the methods with appropriate parameters.
-
Hover mouse:
-
Drag:
In Mobile Applications
-
Touches and long touches:
LongTouch
Note: On Android devices, the HoldDuration parameter of the method is not supported and will be ignored.By default, these methods simulate touches at the center of the specified area. To simulate clicks at a specific point of the area, call the methods with the appropriate parameters.
-
Drag:
See Also
Optical Character Recognition
About Optical Character Recognition
About Mobile Screen Window
Selecting an Object on the Mobile Screen (Android Testing)
Select an Object on the Mobile Screen (iOS Testing)