2

I'm writing test cases to validate the maps using Selenium webdriver. When I try to open the maps using url then location alert is popped up.

enter image description here

I want to allow the map to access the current location by default when the map is loaded without location alert.

I have tried using profile in the ChromeOptions but it is not satisfying my requirements.

Map<String, Object> prefs = new HashMap<String, Object>();
Map<String, Object> profile = new HashMap<String, Object>();
prefs.put("profile.default_content_setting_values.geolocation", 1); // 1:allow 2:block
options.setExperimentalOption("prefs", prefs);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
webDriver = new ChromeDriver(capabilities);

Any help would be appreciated.

derloopkat
  • 6,232
  • 16
  • 38
  • 45
light_ray
  • 642
  • 2
  • 11
  • 31

1 Answers1

2

use:

 googlegeolocationaccess.enabled

Please try:

Map<String, Object> prefs = new HashMap<String, Object>();
Map<String, Object> profile = new HashMap<String, Object>();
prefs.put("googlegeolocationaccess.enabled", true);
prefs.put("profile.default_content_setting_values.geolocation", 1); // 1:allow 2:block
prefs.put("profile.default_content_setting_values.notifications", 1);
prefs.put("profile.managed_default_content_settings", 1);
options.setExperimentalOption("prefs", prefs);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
webDriver = new ChromeDriver(capabilities);
PDHide
  • 18,113
  • 2
  • 31
  • 46