Applies to TestComplete 14.10, last modified on June 5, 2019

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.

Running a Gesture From the Mobile Screen Window

To run a gesture from the Mobile Screen window:

  • Press  Play Gesture on the Mobile Screen toolbar.

  • 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:

  • Open the Gestures editor.

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

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

Running a Gesture From the Project Explorer Panel

To run a gesture from the Project Explorer panel:

  • Expand the AndroidGesturesCollection item in the Project Explorer panel.

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

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

Running a Gesture as a Test Item

To execute a gesture as a test item:

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

  • Select your project in the Project Explorer and then select View | Organize Tests from the main menu of TestComplete. This will open the Test Items page of the project editor.

  • Click New Test Item on the toolbar of the Test Items page.

    A new top-level test item will be added.

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

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

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

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

  • 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
Testing Android Applications
Gesture Object

Highlight search results