Disable GPS Location in Mobile Emulation

423 views
Skip to first unread message

ben...@gmail.com

unread,
Apr 17, 2017, 6:50:19 PM4/17/17
to ChromeDriver Users
Hello,

I'm using Python with Chromedriver/Selenium. When searching websites using the Chromedriver with mobile emulation enabled, I receive the following error message: "We can't access your GPS location. Set a default location to get better local results."

Image of alert: https://i.stack.imgur.com/HRRjj.png

Is there a setting I can add that will ignore this pop-up or turn off GPS location?

I have tried the following in Python with no luck. It turned off the location in content settings, but that looks to be the wrong place.

'profile.content_settings.exceptions.geolocation': 2


Thanks!

gmani...@google.com

unread,
Apr 18, 2017, 1:44:43 PM4/18/17
to ChromeDriver Users, ben...@gmail.com
Seems that Chrome preferences have slightly changed.

You may try setting 'profile.default_content_setting_values.geolocation': 2

ben...@gmail.com

unread,
Apr 18, 2017, 2:35:31 PM4/18/17
to ChromeDriver Users, ben...@gmail.com
On Tuesday, April 18, 2017 at 10:44:43 AM UTC-7, gmani...@google.com wrote:
> Seems that Chrome preferences have slightly changed.
>
>
> You may try setting 'profile.default_content_setting_values.geolocation': 2
>

Forgot to mention I tried a few others:

prefs = {
'profile.default_content_setting_values.notifications': 2,
'profile.content_settings.exceptions.notifications': 2,
'profile.managed_default_content_settings.notifications': 2,
'profile.default_content_settings.geolocation': 2,
'profile.default_content_setting_values.geolocation': 2,
'profile.content_settings.exceptions.geolocation': 2,
'profile.managed_default_content_settings.geolocation': 2,
'profile.default_content_setting_values.popups': 2,
'profile.content_settings.exceptions.popups': 2,
'profile.managed_default_content_settings.popups': 2
}

I checked, and these did change the settings in chrome://settings/content, however, the alert still shows.

I'm using chromedriver 2.21, chrome v53 on raspberrypi. This was the only driver I found in ARM arch, so upgrading the chromedriver is not an option as I do not know how to compile it in ARM and haven't found anyone that has yet.

I have tried WebDriverWait with switch_to_alert and dismissing the alert. This actually works, but it hangs. It takes ~5min for WebDriverWait and ~5min to dismiss the alert, then continues normally.

Reply all
Reply to author
Forward
0 new messages