Disable browser location on Execution

I’d like to lunch the browser both local and remote execution without using the browser locations feature. How can I achieve that?

Thanks.

Can you explain a bit more?

Sure, when I execute a particular script that involves geolocation it uses the browser’s location feature from Chrome. This means that I get different results when I am at the office or home.

I am just wondering if there is a flag or something that I can set so that when the browser is launched, the locations feature is blocked so that I can get consistent results based on user input.

Hope that explains it. Thanks!

Sit tight.

@Brandon_Hein?

You’ll definitely need to set a Desired Capability for this. The trick is figuring out which one. Luckily I have a guide for it:

Thank you for the reply, however, I am still facing the issue after trying the suggested solution.

2021-10-07 14:10:57.983 INFO c.k.k.core.webui.driver.DriverFactory - Starting ‘Chrome’ driver
Oct 07, 2021 2:10:57 PM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using new ChromeOptions() is preferred to DesiredCapabilities.chrome()
2021-10-07 14:10:57.998 INFO c.k.k.c.w.util.WebDriverPropertyUtil - User set preference: [‘acceptInsecureCerts’, ‘true’]
2021-10-07 14:10:57.999 INFO c.k.k.c.w.util.WebDriverPropertyUtil - User set preference: [‘args’, ‘[disable-infobars]’]
2021-10-07 14:10:57.999 INFO c.k.k.c.w.util.WebDriverPropertyUtil - User set preference: [‘pref’, ‘{dir=C:\Users\USERFOLDER\AppData\Local\Temp\scoped_dir36424_1848640927\Default\Preferences.txt, default_content_setting_values.geolocation=false, default_content_settings.geolocation=false}’]
2021-10-07 14:10:58.018 INFO c.k.k.core.webui.driver.DriverFactory - Action delay is set to 0 milliseconds

The browser still opens with the geolocation turned on.

What am I missing? Is it possible to launch the browser with the geolocation turned off?

Try the args provided in this post:

both in the question as well as the accepted answer. Also, it looks like they are passing this as args, not prefs.

The following settings worked for me. Workaround was to launch incognito and disable permissions prompt.

3 Likes