How To Set Fake Location For Testing Location-Based Web Applications On Chrome

    Mohanraj Kumar
Mohanraj Kumar

Web applications may need some time to access your location in order to show relevant data. For instance, while looking for hotels in a particular location on a website, the maps in the application may use the current geolocation to display hotels that are nearby, so while testing, the question that arises is how to test the application for various location without being in that place in real time?

In early days the websites used IP address to find out the approximate location but today with Geolocation API, browsers can detect your location accurately.

There are lot of 3rd party browser plugins for faking locations which sometimes may have adware or install unwanted programs on the machine so the safest would be to use Google Chrome and manipulate the geo location.

Here’s how.

Step-1:

Open the Chrome browser in your test environment

Step-2:

Right click on your testing site and select ‘Inspect’ (or) simply press ‘F12’

Step-3:

Click on ‘More’ à More tools à Sensors as per the image below.

The Beginner’s Guide To Set Fake Location For Testing Of Location-Based Web Applications On Google Chrome

Step-4:

Choose ‘Geolocation’ as Custom Location (or) we can choose any predefined locations.
 
Step-5:

All you need to do is fill the ‘Latitude & Longitude’ coordinate of your testing location as per the requirement.

The Beginner’s Guide To Set Fake Location For Testing Of Location-Based Web Applications On Google Chrome

Step-6:

Reload the web page. Now, the website is ready for testing. Thus, on opening the application, the browser will always ask for a confirmation before sharing your location accept the same and continue to do the required testing.

Simulating a location is simple on following the above steps using Google Chrome and this helps to test if the application behaves properly at different locations.