Geolocation-based testing has become crucial in today’s tech landscape, especially when users are scattered across different regions.Conducting physical tests with users everywhere is impractical, and this is where location spoofing comes into play as a practical solution.

This post delves into the significance of location spoofing in testing applications and beyond.

Geolocation refers to the use of location technologies such as GPS or IP addresses to identify and track the whereabouts of connected electronic devices. Geolocation is frequently used to track people’s movements and locations as well as for surveillance purposes because people frequently carry these devices.Testing an application in different geographic locations to ensure that it meets all legal requirements related to those locations and works as expected regardless of location.This includes checking the validity of the application in each geographic location where it may be used, checking the application efficiency and performance of IP in various locations.

Location spoofing is a form of interference which makes the receiver believe, user is at a false location. By faking or manipulating the GPS coordinates of a device, it can help a user spoof their current location.

Need for Location Spoofing

The main purpose of location spoofing in testing is to simulate different locations in order to assess how a service or application performs under different circumstances like allowing food ordering from a restaurant only if user is at restaurant’s location, greeting users based on location or getting details of a place only when user is at that specific place.

Location Spoofing Across Multiple Platforms

In Android Devices using Fake GPS App

Fake GPS is a reliable and convenient fake location app. The Fake GPS app allows you to choose a location anywhere in the world from its multiple location support.

Steps to Spoof Location:

  1. Install the app from play store.
    App Installation
  2. Open the app.
    App Launch
  3. Tap on the ellipsis on the top right corner.
    App options
  4. Tap on Search.
  5. Enter the coordinates.
    Enter coordinates
  6. Set the mock location in the Developer option by selecting “Fake GPS” app in Select mock location app option.
  7. Tap on the play icon in the menu bar when you want to start.
    Start mocking
  8. Tap on pause icon in the menu bar when you want to stop.
    Stop mocking

In iOS Devices

In iOS, it is a bit tricky to spoof locations. Developers can provide an option in development builds from app settings to mock location programmatically.

Given below is the conceptual overview to set up location spoofing based on Settings bundle:

  1. Use the Settings bundle to store key-value pairs accessible via the app’s settings.

    a. Text inputs may be most straight-forward for latitude and longitude; sliders or toggles are also available

    b. For fixed locations, a list of map values with corresponding coordinates ensures correct inputs

    c. Additionally, include a toggle that can enable/disable the app from using the spoofed location

  2. Read values from the Settings bundle whenever applicable (this will depend on app architecture)

    a. Usually an iOS app will contain a single Location Manager. Intercepting the manager’s coordinates and replacing with the spoofed location is often the simplest approach

    b. Occasionally the app’s architecture will retain reference to a previous location; a user can either restart the app, or the engineer can design to detect changes for when location spoofing is enabled/disabled on each app open

    c: In the case a Location Manager is not the source of truth, each location within the app will need to read from the Setting’s spoofed location (more cumbersome to maintain; prone to human error).

Note: Additional steps may be needed, such as injecting the spoofed location into a map for accuracy. For device-level spoofing, connect to Xcode and run the app on the simulator.

Steps to Spoof Location:

  1. Install the app.
  2. Open app settings from native iOS Settings app.
    iOS native app settings
  3. You will find an option to enter coordinates(If added by developer) or an option to select location from a list.
    iOS Mock Location
  4. Save the values entered and on launching the app now, you can see mocked locations.

On Chrome Browser

Spoofing location can be done on browser’s also and here are the steps for spoofing location on chrome browser using developer tools.

Steps to Spoof Location:

  1. Open the website where the location is to be spoofed.
  2. Press command+option+J to open Developer tool or Right click and click on Inspect to open Developer tool.
  3. Click the three vertical dots in the upper right of the developer tools panel.
  4. Click on More tools and then click on Sensors.
  5. Click on Manage.
  6. Click on Add Location.
  7. Add name, latitude and longitude of the location and then click on Add button.
  8. Click on cancel icon and select the added location.
  9. To verify the location has been updated, try fetching the current location and you should see the updated location.

Using Browserstack App Live

Browserstack supports geolocation testing and hence we used it for testing both Android and iOS applications. By providing coordinates or selecting location from browserstack.Browserstack mocks the location by mocking the device’s current location from the testing lab.

Steps to Spoof Location:

  1. Click on Change location.
  2. Enter the latitude and longitude.
  3. Confirm the location by clicking on Yes.

As technology continues to advance, the importance of location spoofing in testing and real-world scenarios cannot be overstated. From ensuring application functionality across diverse locations to exploring its potential in everyday scenarios like food ordering, location spoofing proves to be a versatile and indispensable tool in the tech enthusiast’s toolkit.

We trust that this blog has provided valuable insights into the concept of location spoofing and the key techniques that can be employed to achieve spoofing.

Thank you Navneet Kaur, Vishnu Vijayakumar and Pooja Padamad for your contribution to this blog.