Please, see the following screenshot:
How can I handle Geo Location popup in mozilla and chrome browser using selenium webdriver?
package tiyotesting;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.support.ui.Select;
public class Citydropdownlist {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
driver.get("http://ec2-35-154-164-82.ap-south-1.compute.amazonaws.com/tiyorelease3/");
WebElement ListBox = driver.findElement(By.id("supported_city_label"));
ListBox.sendKeys("Ahmedabad");
ListBox.sendKeys(Keys.ENTER);
}
}
I created Firefox custom profile it is also not working again the popup came it is showstopper for me, so please help me to resolve the issue
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/");
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With