Overview
This guide explains how mocked GPS locations behave in TestGrid and outlines recommended practices for ensuring consistent and reliable location-based testing. Since mocked GPS coordinates persist at the device level, they remain active across sessions until explicitly changed. Implementing location reset steps before test execution helps prevent unexpected behavior and ensures predictable test results.
Prerequisites
- Access to modify test scripts or test setup steps.
Understanding Mock GPS Persistence
When a mock GPS location is applied to a device:
The location remains configured on the device after the session ends.
Deactivating or reactivating the device does not reset the mocked location.
The location persists across multiple test executions.
Other users accessing the same device may inherit the previously configured location.
This behavior is expected and designed to preserve device-level configuration.
Impact on Testing
If GPS locations are not explicitly managed, you may experience:
Inconsistent results in location-based test cases.
Test failures caused by unexpected location data.
Shared devices retaining GPS coordinates from previous executions.
Unpredictable behavior across test environments.
Recommended Approach
Step 1: Add a GPS Reset Precondition
Include a location reset step before executing location-dependent test cases.
This ensures that every execution begins from a known location state.
Sample Code -
Use custom function to define the required coordinates.
Example
((IOSDriver) driver).setLocation(new Location(latitude, longitude, altitude));
If required, reset the device to a predefined default location before running tests.
Example
((IOSDriver) driver).setLocation(new Location(34.087021, -84.252228, 0));Step 2: Execute the Test
Run the test only after the location reset step has completed successfully.
Best Practices
✔ Always reset the GPS location before running location-based tests.
✔ Use predefined coordinates for repeatable test execution.
✔ Implement reusable functions to manage GPS configuration across test suites..
✘ Do not assume device restart, deactivation, or reactivation will reset GPS coordinates.
✘ Do not rely on the previously configured location from earlier test executions.
Outcome
By explicitly configuring GPS coordinates before execution, location-based tests become predictable, repeatable, and independent of previous device activity, resulting in more reliable automation outcomes.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article