Question: I want to share my location on click of 'Share Location' button on the popup. How can I handle this using selenium webdriver? Refer image below.

Steps to reach to Location popup: 

1. Navigate to [this URL](http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation)
2. Click on `Try it` button from right section
3. Location popup will be displayed as :

[![https](https://i.stack.imgur.com/8zQFC.png)](https://i.stack.imgur.com/8zQFC.png)

Answer: 
So lets say if for launching any site, this `GeoLocation` pop up comes, You can't interact with this element as its not a `WebElement`, so you have to handle it before the browser launches a site so below are the properties you need to set to launch the browser:-

**For Firefox:**

```
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);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, geoDisabled);
driver = new FirefoxDriver(capabilities);

```

**For Chrome:**

```
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("test-type");
options.addArguments("enable-strict-powerful-feature-restrictions");
options.addArguments("disable-geolocation");
cap.setCapability(ChromeOptions.CAPABILITY, options);
cap = cap.merge(DesiredCapabilities.chrome());
driver = new ChromeDriver(cap);

```

Hope it helps!
```
    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);
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability(FirefoxDriver.PROFILE, geoDisabled);

    WebDriver driver;
    System.setProperty("Driver_Name", "Driver_path");
    driver =new FirefoxDriver(geoDisabled);

```

Need to pass the instance of FirefoxProfile.