Legacy | Set device location
-
Command: location
-
Subcommand: set
-
Supported Platforms: Native (legacy), UFT (legacy), Selenium, Appium
All commands must be executed using the same framework. Sharing the execution ID between different frameworks is not possible. This means that if you work with a Selenium/Appium driver, you need to call the commands using the Selenium/Appium driver (or, in the case of Reporting commands, through the Reporting SDK that works with the driver) and not as part of a UFT test or another framework.
-
Supported OS: Android, iOS
Description
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.
Set the device location via address
Setting location via address requires using Google Geocoding. For example: 1600 Amphitheatre Parkway, Mountain View, CA.
Set the device location via coordinates
Many applications supply GPS coordinates when given a Google Geocoding formatted address. 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" .
Once these GPS coordinates are obtained, you can set the device location via the Set device location command.
To obtain Google coordinates for an address, use Google Maps.
Troubleshoot location setting
If the Set device location command does not work:
- Confirm that the
Reset Location
parameter is set tofalse
. - Open, close, and reopen the application in which the location is set.
On Android, verify the following settings on the device:
-
Allow mock locations:
Go to Settings > Developer options > Allow mock locations.
-
High accuracy:
Go to Setting > Location > Mode > High accuracy.
Parameters
Name | Value | Default | Description |
---|---|---|---|
deviceID* | The device for this command. | ||
address |
The address location to set. Format: Google Geocoding. Example: 1600 Amphitheatre Parkway, Mountain View, CA |
||
coordinates |
The latitude and longitude coordinate of the device location to set. Example: 43.642659,-79.387050 |
* Mandatory
Request & Response
Request
https://mycloudlab.perfectomobile.com/services/executions/john@perfectomobile.com_controller_16-11-09_11_30_56_337?operation=command&securityToken=<your_token>&command=location&subcommand=set¶m.deviceId=9A72917FF7B5109B54FD96C4C56A6C128E23F018¶m.address=1600%20Amphitheatre%20Parkway,%20Mountain%20View,%20CA
JSON response
{
"executionId": "john@perfectomobile.com_controller_16-11-09_11_30_56_337",
"reason": "Success",
"timer.elapsed": "1125",
"testGridReportUrl": "https://mycloudlab.reporting-stg.perfectomobile.com?externalId[0]=john@perfectomobile.com_controller_16-11-09_11_30_56_337",
"timer.ux": "0",
"singleTestReportUrl": "https://mycloudlab.perfectomobile.com/nexperience/singletest/report/?reportRepositoryKey=PRIVATE:controller/161109/controller_16-11-09_11_30_56_337.xml&ownerId=john@perfectomobile.com&sharingCode=8b1b44f9-986b-4a7a-8214-b9171d6a30a1",
"description": "Success",
"timer.system": "1125",
"reportKey": "PRIVATE:controller/161109/controller_16-11-09_11_30_56_337.xml",
"completed": "true",
"flowEndCode": "SUCCEEDED",
"timer.device": "0"}