0

Trying to disable the Geolocation prompt of Firefox where it asks for the permission to locate the user. I have read many posts in the internet and tried different things but it does not work. Firefox asks me everytime for a permission. I want to automate the test and I do not work to allow it everytime.

My current code:

FirefoxProfile fireFoxProfile = new FirefoxProfile("firefoxProfile");
fireFoxProfile.SetPreference("geo.prompt.testing", true);
fireFoxProfile.SetPreference("geo.prompt.testing.allow", true);
FirefoxOptions firefoxOptions = new FirefoxOptions() {
                Profile = firefoxProfile
            };
fireFoxDriver = new FirefoxDriver(geckoDriverPath, firefoxOptions);
La0x1
  • 115
  • 2
  • 10

1 Answers1

0

You missed one more preference. This will allow the geolocation by default and will not prompt during test.

FirefoxProfile fireFoxProfile = new FirefoxProfile("firefoxProfile");
fireFoxProfile.SetPreference("geo.enabled", true);
fireFoxProfile.SetPreference("geo.prompt.testing", true);
fireFoxProfile.SetPreference("geo.prompt.testing.allow", true);
FirefoxOptions firefoxOptions = new FirefoxOptions() {
                Profile = firefoxProfile
            };
fireFoxDriver = new FirefoxDriver(geckoDriverPath, firefoxOptions);
Navarasu
  • 6,991
  • 2
  • 19
  • 31
  • It does not work. Copied it exactly and Firefox still asks me for the permission. – La0x1 Nov 02 '18 at 16:27
  • Actually i have checked in java binding. I am able to reproduce the issue. Then adding the preference solved for me. I have use this site for verification. https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation. Let me check c#. – Navarasu Nov 02 '18 at 17:36