1

I try to set permission but nothing happends. I insert this code to devtools protocol monitor

{
    "command":"Browser.grantPermissions",
    "parameters":
        {
            "permissions": ["geolocation"]
        }
}
Mr Dobish
  • 11
  • 2

1 Answers1

1

I experienced the same issue using Selenium + Python. Here is my setting:

chrome_driver.execute_cdp_cmd(
    cmd="Browser.grantPermissions",
    cmd_args={
        "permissions": ["geolocation"]
    }
)
chrome_driver.execute_cdp_cmd(
    cmd="Emulation.setGeolocationOverride",
    cmd_args={
        "latitude": 37.7749,
        "longitude": 122.4194,
        "accuracy": 1000
    }
)

I've used https://browserleaks.com/geo to test if geolocation identified or not.

After several tries and guesses I've found out that I never granted global MacOS permission to Chrome:

MacOS -> System Preferences... -> Security & Privacy -> Location Services

Go to MacOS -> System Preferences... -> Security & Privacy -> Location Services and enable location services for Chrome.

After this, the geolocation worked fine.

Vladimir Obrizan
  • 2,538
  • 2
  • 18
  • 36