Swipe Method

Applies to TestComplete 14.71, last modified on April 22, 2021

Description

Simulates touching the screen at the specified point, moving to the desired point and then releasing the screen.

Declaration

ProgObj.Swipe(StartXStartYEndXEndYStepsDuration)

ProgObj An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section
StartX [in]    Required    Integer    
StartY [in]    Required    Integer    
EndX [in]    Required    Integer    
EndY [in]    Required    Integer    
Steps [in]    Optional    Integer Default value: 10   
Duration [in]    Optional    Integer Default value: 1000   
Result None

Applies To

The method is applied to the following objects:

Parameters

The method has the following parameters:

StartX

Specifies the horizontal coordinate (in pixels) of the start point of the drag action.

StartY

Specifies the vertical coordinate (in pixels) of the start point of the drag action.

EndX

Specifies the horizontal coordinate (in pixels) of the end point of the drag action.

EndY

Specifies the vertical coordinate (in pixels) of the end point of the drag action.

Steps

Specifies the number of interpolating steps.

Duration

Specifies the time of dragging in milliseconds.

Result Value

None.

Remarks

This method is asynchronous. This means that TestComplete continues running the test, no matter whether it has finished or not. For information on how it may affect testing on Android devices, see Possible Issues.

Example

The example below demonstrates how to use the Swipe method:

JavaScript, JScript

function Test()
{
  // Specify the current device
  Mobile.SetCurrent("MyDevice");

  // Launch the tested application
  …

  // Simulate user actions
  …
  Mobile.Device().Swipe(5, 5, 55, 55, 1500);
  …

}

Python

def Test():
  # Specify the current device
  Mobile.SetCurrent("MyDevice")

  # Launch the tested application
  # ...

  # Simulate user actions
  # ...
  Mobile.Device().Swipe(5, 5, 55, 55, 1500)
  # ...

VBScript

Sub Test

  ' Specify the current device
  Call Mobile.SetCurrent("MyDevice")

  ' Launch the tested application
  …

  ' Simulate user actions
  …
  Call Mobile.Device.Swipe(5, 5, 55, 55, 1500)
  …

End Sub

DelphiScript

procedure Test;
begin
  // Specify the current device
  Mobile.SetCurrent('MyDevice');

  // Launch the tested application
  …

  // Simulate user actions
  …
  Mobile.Device.Swipe(5, 5, 55, 55, 1500);
  …

end;

C++Script, C#Script

function Test()
{
  // Specify the current device
  Mobile["SetCurrent"]("MyDevice");

  // Launch the tested application
  …

  // Simulate user actions
  …
  Mobile["Device"]["Swipe"](5, 5, 55, 55, 1500);
  …

}

See Also

Testing Mobile Applications
Drag Method
Touch Method
TouchAndHold Method
AndroidDevice Object
iOSDevice Object

Highlight search results