0

When I execute this code :

ChromeDriver driver = new ChromeDriver();
//40 3
    
DevTools devTools = driver.getDevTools();
devTools.createSession();
    
Map<String,Object>coordinates = new HashMap<String,Object>();
    
coordinates.put("latitude", 40.427939382087814);
coordinates.put("longitude", -3.7056416054815884);
coordinates.put("accuracy", 1);
driver.executeCdpCommand("Emulation.setGeolocationOverride", coordinates);
driver.get("http://google.com");

Chrome don't change the location : selenium4, chrome 95

Message in console :

WARNING: Unable to find an exact match for CDP version 95, so returning the closest version found: 91 oct. 28, 2021 4:13:19 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch INFO: Found CDP implementation for version 95 of 91

Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95
MounaG
  • 15
  • 4
  • I'm not sure if this helps or is relevant. I placed your settings into my selenium 4 project ChromeDriverFactory.class and I never got the 'Warning' that you can see. My browser is also v95.0.4638.54. I didn't get a chance to check location details yet, but I noticed in my .m2 repository, for selenium 4 I do have the following: selenium-devtools-v85, 88, 89, 90, 91, 93 and 95. Do you have the same ? – djmonki Oct 28 '21 at 21:11
  • hello, yes i have that folders. i will try to change chrome cersion and verify if it changes the location. – MounaG Oct 29 '21 at 07:33
  • when i try : driver.get("https://my-location.org/"); it gives me the location in the script , but with driver.get("http://google.com"); gives me my real location – MounaG Oct 29 '21 at 07:44
  • It seems that it detects the location , because when i seach in google it gives me the choices adapted to that location , but google gives me my correct location (in the bottom right.). thakyou @djmonki for your help – MounaG Oct 29 '21 at 08:08

0 Answers0