Swipe (FR)

Perfecto Command

mobile:touch:swipe

Purpose

Performs the swipe gesture, which is a three-part gesture:

  • A touchdown at the start coordinates
  • A move to the end coordinates
  • A touch-up at the end coordinates

The relationship between the start and end coordinates defines the direction vector of the swipe. It is possible to also define the time frame of the swipe. 

The start and end coordinate values can be in pixels or in percentage. Always use the same type for both coordinates.

The (0,0) point is in the upper left corner of the screen. The x-coordinate value increases to the right and the y-coordinate value increases to the bottom.

Parameters

Name Type Possible Values Description
start (Mandatory) String

The start, touch down, event coordinates.

Format - "x,y" or "x%,y%"

Coordinate value can be in pixels or in percentage of screen size (0-100).

For percentage use the % sign.

Example - 50%, 50%

It is recommended to use the percentage value as it does not rely on the screen resolution.

end (Mandatory)

String

The end, touch up, event coordinates.

Format - "x,y" or "x%,y%"

Coordinate value can be in pixels or in percentage of screen size (0-100).

For percentage use the % sign.

Example - 50%, 50%

It is recommended to use the percentage value as it does not rely on the screen resolution.

duration Int 1-10 The duration, in seconds, for performing the operation.

Return Value

None

Exceptions

None

Examples

Copy

Java sample

Map<String, Object> params = new HashMap<>();
params.put("start", "20%,40%");
params.put("end", "15%,60%");
params.put("duration", "3");
Object res = driver.executeScript("mobile:touch:swipe", params);
Copy

C# sample

Dictionary<String, Object> pars = new Dictionary<String, Object>();
pars.Add("start", "20%,40%");
pars.Add("end", "15%,60%");
pars.Add("duration", "3");
Object res = driver.ExecuteScript("mobile:touch:swipe", pars);