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.
Open the Chrome browser in your test environment
Right click on your testing site and select ‘Inspect’ (or) simply press ‘F12’
Click on ‘More’ à More tools à Sensors as per the image below.
Choose ‘Geolocation’ as Custom Location (or) we can choose any predefined locations.
All you need to do is fill the ‘Latitude & Longitude’ coordinate of your testing location as per the requirement.
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.Tweet