Set device location (FR)

Perfecto Command

mobile:location:set

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.

The location is supplied as one of the following: Full (street, city, state, country) or partial address OR Latitude, Longitude pair

To set the location via address: This requires using Google Geocoding. For example: 1600 Amphitheatre Parkway, Mountain View, CA.

To set the location via GPS: Many applications supply GPS coordinates when given an address following Google's Geocoding format. For example: Google Maps yields the GPS coordinates 43.642752 (latitude), -79.386981 (longitude) - decimal degrees - for the address "1600 Amphitheatre Parkway, Mountain View, CA."

When you obtain GPS coordinates, you can set the device location via the Set device location command.

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);