Set device location (FR)

Perfecto Command

mobile:location:set

Supported OS: iOS, Android

Purpose

Sets the device location. This enables testing a location-aware app that uses location services without moving the device from place to place to generate location data.

To learn more about location injection, including requirements and limitations, see Location injection overview.

Parameters

Name Type Possible Values Description
address String

The address location to set. Format: Google Geocoding.

Example: 1600 Amphitheatre Parkway, Mountain View, CA

coordinates String

The latitude and longitude coordinate of the device location to set.

Example: 43.642659,-79.387050

Return Value

None

Exceptions

None

Examples

Copy

Java sample

Map<String, Object> params = new HashMap<>();
params.put("address", "4145 Bushnell, University Heights, OH");
driver.executeScript("mobile:location:set", params)
Copy

C# sample

Dictionary<String, Object> pars = new Dictionary<String, Object>();
pars.Add("address", "4145 Bushnell, University Heights, OH");
driver.ExecuteScript("mobile:location:set", pars);