Forum Discussion

vatbub's avatar
vatbub
Contributor
9 years ago

Set Mock location on iOS

Hi there,

I am having again some trouble with TestComplete, this time with fake locations.

I try to set the fake location of an iOS device using the code from this help article.

 

Now, I get two problems:

 

In the line

Mobile.Device.GPS.GPSEnabled = true;

I get "Falsche Anzahl an Argumenten oder ungültige Eigenschaftszuweisung" (Wrong number of arguments or illegal parameter assignment)

 

When I debugged that piece of code, I found out that GPSEnabled was already set to true, so I removed that line for experimental purpose.

 

Now I get the very same error but in the line

Mobile.Device.GPS.SetLocation(Longt,Lat,Alt,Acc);

Please note that the app has granted GPS access (I answered the prompt from iOS with Yes).

 

So I read through TestCompletes help articles and found this article which says:

 

"TestComplete can specify mock location data only when the Allow mock locations setting is enabled in the iOS developer settings."

 

I have no idea if this has something to do with my problem but I couldn't find anything like "Allow mock locations" in the developer options of my iOS device.

 

Thanks for helping,

Greetings,

vat

2 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi Vat,

     

    I believe you need to specify the device name in Mobile.Device():

    Mobile.Device("My iPad").GPS.GPSEnabled = true;

    If you use Mobile.SetCurrent() to specify the device, you still need the parentheses after Device() because it's a method and not a property:

    // JScript
    Mobile.SetCurrent("My iPad");
    ... Mobile.Device().GPS.GPSEnabled = true;

     (Parentheses are optional in this case only when using VBScript or DelphiScript.)

    • vatbub's avatar
      vatbub
      Contributor

      Hi HKosovana,

      thanks for helping although parenthesis didn't do the trick. I still get the same error message in the same lines.

       

      The strange thing is, that on it worked before and still works on Android and even requesting the current location  using

      Mobile.Device.GPS.Location.Longitude

      and checking the GPS Status using

      Log.Message(Mobile.Device.GPS.GPSEnabled);

      works on iOS with and without parenthesis. It's apparently all about setting that information.

      Greetings,

      vat