SetLocation Method (MobileDevice)

Action

Sets the geographic location of the device, this method only works on Android devices (physical or emulated) and iOS simulators.

  • When testing a native mobile application on iOS, the SetLocation method is only supported for iOS simulators, not for physical iOS devices.
  • When testing a native mobile application on an Android version prior to Android 6.0, you have to enable Allow mock locations to use the SetLocation method. To do so, open the settings of the Android device or emulator and tap Developer Options.
  • When testing a native mobile application on Android 6.0 or later, you have to set the app to Appium Settings to use the SetLocation method. To do so, open the settings of the Android device or emulator and tap Developer Options > Select mock location app. Then choose Appium Settings. Note: The Appium Settings entry is only available if you have already executed a test with Appium on the Android device or emulator.

Syntax

C#
device.SetLocation(latitude, longitude)
VB
device.SetLocation(latitude, longitude)
Variable Description
latitude Latitude of the location in degrees and minutes represented as a double value. Double.
longitude Longitude of the location in degrees and minutes represented as a double value. Double.