0

I am trying to set geolocation based on this documentation: https://www.selenium.dev/documentation/en/support_packages/chrome_devtools/

I am using selenium==4.0.0b2

I am running remote webdriver instead of local, and I am getting the following error:

AttributeError: 'WebDriver' object has no attribute 'execute_cdp_cmd'

This is my sample code:

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium import webdriver
import time

driver = webdriver.Remote(
    command_executor='http://localhost:4444/wd/hub',
    desired_capabilities=DesiredCapabilities.CHROME
)
    Map_coordinates = dict({
            "latitude": 21.841,
            "longitude": -97.948,
            "accuracy": 100
        })

print(Map_coordinates)
driver.execute_cdp_cmd("Emulation.setGeolocationOverride", Map_coordinates)

driver.get('http://www.google.com/')
time.sleep(50)

What am I missing??

The Dan
  • 1,408
  • 6
  • 16
  • 41

2 Answers2

0

I also have this problem. But I am using is VB.NET at Visual Studio cannot find any Chrome Devtool. And at the end I found a nuget that is https://github.com/ToCSharp/AsyncChromeDriver You can try to look at.

SampoValo
  • 21
  • 4
0

In my case I was following example from Selenium - python. how to capture network traffic's response and got it working "python3 script.py". After numerous executions started seeing this error due to wrong python version used. If someone has the same error it can happen if system loads python3.6 instead of python3.9 so I needed to specify exact python version.