Execute Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

Emulates the given gesture on the connected mobile device. See Executing Gestures (Multi-Touch Events) (Legacy).

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.

Declaration

GestureObj.Execute()

GestureObj An expression, variable or parameter that specifies a reference to a Gesture object
Result None

Applies To

The method is applied to the following object:

Result Value

None.

Remarks

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

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)
Executing Gestures (Multi-Touch Events) (Legacy)
Simulating Physical Button Events (Legacy)

Highlight search results