Skip to main content

setLocationPlaybackFile

This is an asynchronous operation. It walks through the values in the given file and sets the location after the delay in the delay parameter. This is used to simulate the movement of a device.

Use [waitForSetLocationToEnd](../device-commands/waitforsetlocationtoend.md)(timeout) to verify the task is complete. This command fails the current test in case the location cannot be set.

Use StopLocationPlayback to stop the task early.

This returns true if started successfully.

NameValueDescription
csvPathStringPath to a CSV file with the values (Latitude, Longitude, Altitude). Altitude is supported only for Android devices.
delayintDelay in milliseconds between every mock location.
mockRecieverStringReceiver to use for mocking: gps / network/ gps,network. Supported only for Android.

CSV File Example Expand source

Latitude, Longitude, Altitude
28.70406,77.102493,256.5
28.984463,77.706413,230.2
30.37818,76.776695,282.6
32.259541,75.632072,334
32.726601,74.857025,302.5
34.083672,74.797279,1595.7
34.560131,76.126137,2687.2
34.152588,77.577057,3501
32.239632,77.188713,2050
31.104815,77.173403,2276
30.73827,76.765144,321
26.8465108,80.9466832,123
25.611,85.144,59.46
23.259933,77.412613,500
17.38714,78.491684,536
12.972442,77.580643,923
13.067439,80.237617,6.7
8.524139,76.936638,21.352
info

CSV file upload must be enabled in the settings. For more information, see File Repository.

When using multiple csv files, each task must finish before starting a new one with a different csv file. If a new command is called before the present task finished, the new task is ignored.

You can use waitForSetLocationToEnd(timeout) command with a large enough timeout for the task to finish before calling the next one.

info

The final location set using setLocationPlaybackFile command can be cleared using ClearLocation.