Touch (FR)

Perfecto Command

mobile:touch:tap

Purpose

Performs a touch operation on the specified coordinate location. A long press can be performed by using the durationparameter. A touchdown press is released with a touch- up release.

Important: As a best practice, this command should only be used in extreme circumstances because it is not accurate or adaptable to application modifications. Alternatively, screen analysis functions are recommended for robust automated testing.

Parameters

Name Type Possible Values Description
location (Mandatory) String

The touch event coordinates.

Format - either "x1,y1,x2,y2" or "x1%,y1%,x2%,y2%"

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

For percentage use the % sign. Example - "20%, 25%"

It is recommended to use the percentage value as it translates to the screen resolution.

duration Int

The duration, in seconds, for performing the touch operation.

Use this to perform a "long-press".

Return Value

None

Exceptions

None

Examples

Copy

Java sample

Map<String, Object> params = new HashMap<>();
params.put("location", "20%,27%,20%,65%");
Object res = driver.executeScript("mobile:touch:tap", params);
Copy

C# sample

Dictionary<String, Object> pars = new Dictionary<String, Object>();
pars.Add("location", "20%,27%,20%,65%");
pars.Add("duration", "8");
Object res = driver.ExecuteScript("mobile:touch:tap", pars);