Simulate User Actions

Applies to TestComplete 12.60, last modified on September 17, 2018

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:

Simulate OCR-based user actions in keyword tests
  1. Add the operation to your test.

  2. 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 the Mobile.Device.Desktop property.

  3. 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.

  4. Select the method you want to use to simulate user actions.

  5. 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

OCR.Recognize(Aliases.myApp.wndForm).BlockByText("*clock*", spLargest).Click();

Python

OCR.Recognize(Aliases.myApp.wndForm).BlockByText("*clock*", spLargest).Click()

VBScript

Call OCR.Recognize(Aliases.myApp.wndForm).BlockByText("*clock*", spLargest).Click

DelphiScript

OCR.Recognize(Aliases.myApp.wndForm).BlockByText('*clock*', spLargest).Click;

C#Script

OCR.Recognize(Aliases["myApp"]["wndForm"])["BlockByText"]("*clock*", spLargest)["Click"]();

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
In Mobile Applications
  • Touches and long touches:

    Touch

    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:

    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)

Highlight search results