TestProject Forum

Is there an addon or method for mocking geolocation settings in Desktop browsers such as Chrome or Firefox?

Is there any addon to set up mock location overrides on the desktop browser, so that it will use those, instead of user’s actual location?

Hello @pmeera,

There is way to override your location settings by executing a script using the “Execute JavaScript” addon:

Here is the script:
window.navigator.geolocation.getCurrentPosition = function(success){ var position = {'coords' : { 'latitude': '20', 'longitude': '10'}}; success(position);}

This script overrides the location which is set by the browser, by using the latitude and longitude parameters, which depend on the location you wish to switch to, you can find those by a simple google search, for your location.

You can put parameters as well instead of numbers:


1 Like

Thank you. Tried that and it is working.

The only additional thing that I needed to do was to add ‘Delete all cookies’ as the first step of my test(before you navigate to the application under test).

This cleared all the previous location info, which I had noticed was not happening when I was running the tests repeatedly for different co-ordinates.