我正在尝试根据此文档设置地理位置:https ://www.selenium.dev/documentation/en/support_packages/chrome_devtools/
我正在使用硒==4.0.0b2
我正在运行远程 webdriver而不是本地,我收到以下错误:
AttributeError: 'WebDriver' object has no attribute 'execute_cdp_cmd'
这是我的示例代码:
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)
我错过了什么??