Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

setLocation(Latitude, Longitude)

Supported_os
SupportIOStrue
SupportAndroidtrue

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.

Info

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:

          Code Block
          languagejava
          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:

          Code Block
          languagejava
          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

Code Block
languagejava
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


Info
Note: For the device to return to it’s normal location functioning, it is required to execute the command “clearLocation”.

Code Examples

Code Block
languagejava
titleJava Example
linenumberstrue
client.setLocation("20.593684", "78.962880");
Code Block
languagec#
titleC# Example
linenumberstrue
collapsetrue
client.SetLocation("20.593684", "78.962880");
Code Block
languagevb
titleVBScript Example
linenumberstrue
collapsetrue
client.SetLocation "20.593684", "78.962880"
Report
Code Block
languagepy
titlePython Example
linenumberstrue
collapsetrue
self.client.setLocation("20.593684", "78.962880")
Code Block
languageperl
titlePerl Example
linenumberstrue
collapsetrue
$client->setLocation("20.593684", "78.962880");