Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fake Geolocation in chrome automation

I need to automate geolocation in chrome using python script. I have to fake the latitude and longitude. I followed some links in stackoverflow but they gave errors. chromeDriver.executeScript("window.navigator.geolocation.getCurrentPosition=function(success){var position = {"coords" : {"latitude": "555","longitude": "999"}};success(position);}");

is there any other way i can change the location?

like image 999
user3443200 Avatar asked Oct 18 '25 23:10

user3443200


1 Answers

Using Python with Selenium 3.141 and ChromeDriver 83.0

This is the working method I found:

params = {
  "latitude": 34.0207305,
  "longitude": -118.6919153,
  "accuracy": 100
}
driver.execute_cdp_cmd("Emulation.clearGeolocationOverride", params)
like image 123
Lelouch Avatar answered Oct 20 '25 13:10

Lelouch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!