AndroidGestureCollectionItem Object

Applies to TestComplete 15.73, last modified on March 04, 2025

Description

The AndroidGestureCollectionItem object provides scripting access to a collection of multi-touch events - gestures. See About Gestures (Legacy).

The child objects of AndroidGestureCollectionItem have custom names. They correspond to individual gestures of the collection.

To address a particular gesture from a gestures collection, use the following notation: AndroidGestureCollection.CollectionName.GestureName, 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.

Example

The following code navigates to the Home screen on the mobile device and emulates the SwipeLeft gesture:

JavaScript, JScript

function ExecuteGesture()
{
  Mobile.SetCurrent("MyDevice");

  //Check whether device is connected
  if (Mobile.Device().Connected)
  {
    Mobile.Device().PressButton(mbkHome,aptDownUp);
    AndroidGestureCollection.Default.SwipeLeft.Execute();
  }
  else
    Log.Message("The device is disconnected.")
}

Python

def ExecuteGesture():
  Mobile.SetCurrent("Device")
  # Check whether device is connected
  if Mobile.Device().Connected:
     Mobile.Device().PressButton(mbkHome,aptDownUp)
     AndroidGestureCollection.Landscape.OneTouch.Execute()
  else:
     Log.Message("The device is disconnected.")

VBScript

Sub ExecuteGesture
  Call Mobile.SetCurrent("MyDevice")

  'Check whether device is connected
  If (Mobile.Device.Connected) Then
    Call Mobile.Device.PressButton(mbkHome,aptDownUp)
    Call AndroidGestureCollection.Default.SwipeLeft.Execute()
  Else
    Log.Message("The device is disconnected.")
  End If
End Sub

DelphiScript

procedure ExecuteGesture();
begin
  Mobile.SetCurrent('MyDevice');

  //Check whether device is connected
  if (Mobile.Device.Connected) then
  begin
    Mobile.Device.PressButton(mbkHome,aptDownUp);
    AndroidGestureCollection.Default.SwipeLeft.Execute();
  end
  else
    Log.Message('The device is disconnected.')
end;

C++Script, C#Script

function ExecuteGesture()
{
  Mobile["SetCurrent"]("MyDevice");

  //Check whether device is connected
  if (Mobile["Device"]["Connected"])
  {
    Mobile["Device"]["PressButton"](mbkHome,aptDownUp);
    AndroidGestureCollection["Default"]["SwipeLeft"]["Execute"]();
  }
  else
    Log["Message"]("The device is disconnected.")
}

Note: In this example, the Device.PressButton method is used to navigate to the Home screen, but you can also use the Device.PressHome method for this purpose. For more information, see Simulating Physical Button Events.

See Also

Testing Android Applications (Legacy)
About Script Tests
About Gestures (Legacy)
Gestures Editor (Legacy)

Highlight search results