Executing Gestures (Multi-Touch Events) (Legacy)

Applies to TestComplete 15.47, last modified on January 20, 2023
The information below concerns legacy mobile tests that work with mobile devices connected to the local computer. For new mobile tests, we recommend using the newer cloud-compatible approach.

A gesture can be executed as a test item of a TestComplete project, or it can be executed from the Project Explorer panel, from the Mobile Screen window, from the Gestures editor, from script or a keyword test. You can use any of these approaches that suites your needs best.

Gestures can be recorded and simulated only on devices that support a touch-sensitive interface. Usually, these are hardware devices. Gestures cannot be recorded or played back on virtual machines and emulators, unless they support a touch-sensitive interface.

Currently, TestComplete does not support playing back gestures on devices with Android ver. 10.x - 11.x.

Running a Gesture From the Mobile Screen Window

To run a gesture from the Mobile Screen window:

  1. Press  Play Gesture on the Mobile Screen toolbar.

  2. In the ensuing drop-down list, do one of the following:

    • Select one of the recently executed gestures from the list

    – or –

    • Click Select gesture to display the Select Gesture to Run dialog where you can choose the desired gesture among the available gestures.

Running a Gesture From the Gestures Editor

To run a gesture from the Gestures editor:

  1. Open the Gestures editor.

  2. Right-click the desired gesture in the list and choose Run Gesture from the context menu.

  3. If several mobile devices are connected simultaneously, then specify which of the devices to use in the Select Local Device dialog.

Running a Gesture From the Project Explorer Panel

To run a gesture from the Project Explorer panel:

  1. Expand the AndroidGesturesCollection item in the Project Explorer panel.

  2. Right-click the gesture category node and select Run > Run <Gesture_Name> from the context menu.

  3. If several mobile devices are connected simultaneously, then specify which of the devices to use in the Select Local Device dialog.

Running a Gesture as a Test Item

To execute a gesture as a test item:

  1. Switch to the Project Explorer panel. If it is hidden, choose View > Project Explorer to make the panel visible.

  2. Select your project in the Project Explorer and then select View > Organize Tests from the main menu of TestComplete. This will open the Execution Plan editor of the project.

  3. Click New Test Item on the toolbar of the Execution Plan editor.

    A new top-level test item will be added.

  4. Click the ellipsis button in the Test column of the newly added test item.

  5. In the ensuing Select Test dialog, specify a test that sets a mobile device as the current device for the test session.

    This test should call the Mobile.SetCurrent() scripting method or the Select Device keyword operation.

  6. Click New Test Item once again to add another test item.

  7. Click the ellipsis button in the Test column of the newly added test item and choose the desired gesture using the Select Test dialog.

  8. Select File > Save from the TestComplete main menu to save the changes.

Now the gesture will be executed when you run the project or project suite.

Running a Gesture From Scripts

You can invoke gesture execution from scripts. To run a gesture from script, call the Execute method of the run-time object that corresponds to the desired gesture:

AndroidGestureCollection.CollectionName.GestureName.Execute()

Where CollectionName and GestureName are unique names of the desired collection and gesture. You can view and change collection and gesture names in the Gestures editor.

The Execute method does not return until the gesture is played back completely.

Remember that, you need to specify an Android device or a virtual machine that will be current during testing. In scripts, you do this by calling the Mobile.SetCurrent(...) scripting method before any other test actions:

JavaScript, JScript

Mobile.SetCurrent("MyDeviceName", 0);
AndroidGestureCollection.Default.PinchOpen.Execute();

Python

Mobile.SetCurrent("MyDeviceName", 0);
AndroidGestureCollection.Default.PinchOpen.Execute();

VBScript

Call Mobile.SetCurrent("MyDeviceName", 0)
Call AndroidGestureCollection.Default.PinchOpen.Execute()

DelphiScript

Mobile.SetCurrent('MyDeviceName', 0);
AndroidGestureCollection.Default.PinchOpen.Execute();

C++Script, C#Script

Mobile["SetCurrent"]("MyDeviceName", 0);
AndroidGestureCollection["Default"]["PinchOpen"]["Execute"]();

Running a Gesture From Keyword Tests

To run a gesture from keyword tests, use the Play Gesture operation. When you add it to your test, TestComplete displays a dialog in which you can choose the desired gesture.

Alternatively, you can use the Call Object Method keyword test operation to call the Execute method of the Gesture object (see above).

Remember that, you need to specify an Android device or a virtual machine that will be current during testing. In keyword tests, you do this by calling the Select Device operation before any other test operations.

See Also

About Gestures (Legacy)
Testing Android Applications (Legacy)
Gesture Object

Highlight search results