AllowMockLocations Property

Applies to TestComplete 14.71, last modified on April 22, 2021

Description

Specifies whether mock locations are allowed on the mobile device.

Declaration

Obj.AllowMockLocations

Read-Write Property Boolean
Obj An expression, variable or parameter that specifies a reference to object

Applies To

The property is applied to the following object:

Property Value

True if mock locations are allowed, and False otherwise.

Remarks

Some Android devices disallow changing GPS settings from applications. This limitation is set by the manufacturer and cannot be bypassed. To allow mock locations on such devices, set the required settings manually.

Example

The following example enables mock locations and sets GPS coordinates:

JavaScript, JScript

function Test()
{
  Mobile.SetCurrent("MyDevice");
  Mobile.Device().GPS.AllowMockLocations = true;
  Mobile.Device().GPS.SetLocation(-73.9780035, 40.7056308, 0, 0);
}

Python

def Test():
  Mobile.SetCurrent("MyDevice")
  Mobile.Device().GPS.AllowMockLocations = True
  Mobile.Device().GPS.SetLocation(-73.9780035, 40.7056308, 0, 0)

VBScript

Sub Test()
  Mobile.SetCurrent("MyDevice")
  Mobile.Device.GPS.AllowMockLocations = true
  Call Mobile.Device.GPS.SetLocation(-73.9780035, 40.7056308, 0, 0)
End Sub

DelphiScript

procedure Test();
begin
  Mobile.SetCurrent('MyDevice');
  Mobile.Device.GPS.AllowMockLocations := true;
  Mobile.Device.GPS.SetLocation(-73.9780035, 40.7056308, 0, 0)
end;

C++Script, C#Script

function Test()
{
  Mobile["SetCurrent"]("MyDevice");
  Mobile["Device"].GPS["AllowMockLocations"] = true;
  Mobile["Device"].GPS["SetLocation"](-73.9780035, 40.7056308, 0, 0)
}

See Also

Testing Android Applications
Geolocation Testing
Working With Android Device Settings During Test Run
AndroidGPS Object

Highlight search results