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:
- Install the app from play store.
- Open the app.
- Tap on the ellipsis on the top right corner.
- Tap on Search.
- Enter the coordinates.
- Set the mock location in the Developer option by selecting “Fake GPS” app in Select mock location app option.
- Tap on the play icon in the menu bar when you want to start.
- Tap on pause icon in the menu bar when you want to stop.
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:
-
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
-
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:
- Install the app.
- Open app settings from native iOS Settings app.
- You will find an option to enter coordinates(If added by developer) or an option to select location from a list.
- 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:
- Open the website where the location is to be spoofed.
- Press command+option+J to open Developer tool or Right click and click on Inspect to open Developer tool.
- Click the three vertical dots in the upper right of the developer tools panel.
- Click on More tools and then click on Sensors.
- Click on Manage.
- Click on Add Location.
- Add name, latitude and longitude of the location and then click on Add button.
- Click on cancel icon and select the added location.
- 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:
- Click on Change location.
- Enter the latitude and longitude.
- 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.