SeeTestAutomation- SetLocation
Please note that this tool is classified as a Legacy tool. We recommend transitioning to our updated solutions to maintain optimal performance and security in your workflows. For more information on this matter, please reach out to technical support .
setLocation(Latitude, Longitude)
Description
The command gives the ability to test geolocation based applications by allowing the user to set the location of the device as necessary for testing. It is assumed that the user has pre-configured the device for location testing.
Notes:
- In Android, command supported since Android 4.4.
- Pre-requests**:** Enable the location provider service you wish to work with, by:
- For Android:
- SetProperty. For example:
if you want to the command to work based on GPS only .i.e. 'Device Only Mode', prior to setLocarion, call:
client.setProperty("location.service.gps", "true");
client.setProperty("location.service.network", "false");if you want to the command to work based on GPS and Network .i.e. 'High Accuracy Mode', prior to setLocarion, call:
client.setProperty("location.service.gps", "true");
client.setProperty("location.service.network", "true");- For iOS:
- on your device: Go to: Setting >> Privacy >> Location Services >> enable "Locations Services".
Parameters
- Latitude: Latitude value in decimal degrees, ranging from -90 to 90.
Positive values represent latitudes north of the equator while negative values represent latitudes south of the equator. - Longitude: Longitude value in decimal degrees, ranging from -180 to 180.
Positive values represent longitudes east of the prime meridian while negative values represent longitudes west of the prime meridian.
Usage
client.setDevice("adb:GT-I9505");
client.setLocation("20.593684", "78.962880"); // India
client.setLocation("-32.269794", "26.191406"); // South Africa
client.setLocation("36.296238", "-91.933594"); // USA
Note: For the device to return to it’s normal location functioning, it is required to execute the command "clearLocation".
Code Examples
Java Example
client.setLocation("20.593684", "78.962880");
C# Example Expand source
client.SetLocation("20.593684", "78.962880");
VBScript Example Expand source
client.SetLocation "20.593684", "78.962880"
Report
Python Example Expand source
self.client.setLocation("20.593684", "78.962880")
Perl Example Expand source
$client->setLocation("20.593684", "78.962880");