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: "x,y" or "x%,y%"

The 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 because 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%");
driver.executeScript("mobile:touch:tap", params);
Copy

C# sample

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