I am using the below code and found that I am not able to override the geolocation of my browser using CDP command.
ChromiumDriver driver = new ChromeDriver(); //Initializing the Chrome driver
driver.manage().window().maximize(); //Maximizing the browser to make it fullscreen
DevTools devTools = driver.getDevTools();//getting teh devtools object from the driver
devTools.createSession();//Creating a devTool session
Map<String, Object> place = new HashMap<String, Object>();//Creating a map with geolocation data
place.put("latitude", 19);
place.put("longitude", 73);
place.put("accuracy", 1);
driver.executeCdpCommand("Emulation.setGeolocationOverride", place);//This is suppose to override the browser's current geolocation to Navi Mumbai's one as latitude 19 and longitude 73 is for Navi Mumbai
driver.get("https:google.com");
driver.findElement(By.name("q")).sendKeys("Places near me", Keys.ENTER);//Entering places near me in google search and click on enter
System.out.println(driver.findElement(By.xpath("//span[text()='Results for ']/following-sibling::span[2]")).getText());//This should fetch place that is currently overridden in the browser, but it is still fetching me my current location
Note: I am currently using Chrome 127 and Selenium 4.23.0
I have tried to refresh the page and also tried with Edge browser as it is also a chromium based browser and found that even edge is returning the my current location rather than the overriding the location that I provided in the prameters.