AllowMockLocations Property

Applies to TestComplete 15.20, last modified on January 19, 2022
The information below concerns legacy mobile tests that work with mobile devices connected to the local computer. For new mobile tests, we recommend using the newer cloud-compatible approach.

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 (Legacy)
Geolocation Testing (Legacy)
Working With Android Device Settings During Test Run (Legacy)
AndroidGPS Object

Highlight search results