Because I achieved the same problem almost 3 years after this question was asked, and none of the above answers satisfied me. I like to show the solution I'm using.
So, the answer I found on this blog .
And use it on my Python code as follows:
@classmethod def setUpClass(cls): cls.binary = FirefoxBinary(FF_BINARY_PATH) cls.profile = FirefoxProfile() cls.profile.set_preference("geo.prompt.testing", True) cls.profile.set_preference("geo.prompt.testing.allow", True) cls.profile.set_preference('geo.wifi.uri', GEOLOCATION_PATH) cls.driver = Firefox(firefox_binary=cls.binary, firefox_profile=cls.profile)
On GEOLOCATION_PATH - my path to the JSON file:
{ "status": "OK", "accuracy": 10.0, "location": { "lat": 50.850780, "lng": 4.358138, "latitude": 50.850780, "longitude": 4.358138, "accuracy": 10.0 } }
source share