screen shot for my questionHow can I handle Geo Location popup in mozilla and chrome browser using selenium webdriver?
package tiyotesting;
import ja
The usage initialization of firefox Driver with a FirefoxProfile object has been deprecated. I've used that instead, adding the same preferences. And It worked for me
File gecko = new File("C:\\geckodriver\\geckodriver.exe");
FirefoxOptions ffopt = new FirefoxOptions()
.addPreference("dom.webnotifications.enabled", false)
.addPreference("geo.enabled", false)
.addPreference("geo.provider.use_corelocation", false)
.addPreference("geo.prompt.testing", false)
.addPreference("geo.prompt.testing.allow", false);
System.setProperty("webdriver.gecko.driver", gecko.getAbsolutePath());
WebDriver driver = new FirefoxDriver(ffopt);
While working with Selenium 3.x, geckodriver v0.16.1 & Mozilla Firefox 53.x, you can disable the Geo Location popup by setting the preferences in the new Firefox profile as follows:
System.setProperty
driver.get("http://www.google.com");
to open any other URL.Here is the working set of minimal code which opens the intended URL without the Geo Location popup.
System.setProperty("webdriver.gecko.driver", "C:\\your_directory\\geckodriver.exe");
FirefoxProfile geoDisabled = new FirefoxProfile();
geoDisabled.setPreference("geo.enabled", false);
geoDisabled.setPreference("geo.provider.use_corelocation", false);
geoDisabled.setPreference("geo.prompt.testing", false);
geoDisabled.setPreference("geo.prompt.testing.allow", false);
WebDriver driver=new FirefoxDriver(geoDisabled);
driver.get("http://ec2-35-154-164-82.ap-south-1.compute.amazonaws.com/tiyorelease3/");