How can I handle location pop up on Chrome with Java-TestNG?
Hello Macy,
You can refer to the sample code snippet below to handle location pop up on Chrome with Java-TestNG:
// SET CHROME OPTIONS
// 0 - Default, 1 - Allow, 2 - Block
contentSettings.put("geolocation", 1);
profile.put("managed_default_content_settings", contentSettings);
prefs.put("profile", profile);
options.setExperimentalOption("prefs", prefs);
// SET CAPABILITY
caps.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
driver.get("https://the-internet.herokuapp.com/geolocation");
driver.findElement(By.xpath("//*[@id='content']/div/button")).click();
Thread.sleep(5000);