[英]AttributeError: 'WebDriver' object has no attribute 'execute_cdp_cmd'
I am trying to set geolocation based on this documentation: https://www.selenium.dev/documentation/en/support_packages/chrome_devtools/我正在尝试根据此文档设置地理位置: https://www.selenium.dev/documentation/en/support_packages/chrome_devtools/
I am using selenium==4.0.0b2我正在使用硒==4.0.0b2
I am running remote webdriver instead of local, and I am getting the following error:我正在运行远程 webdriver而不是本地,我收到以下错误:
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??我错过了什么??
I also have this problem.我也有这个问题。 But I am using is VB.NET at Visual Studio cannot find any Chrome Devtool.但我在 Visual Studio 中使用的是 VB.NET 找不到任何 Chrome 开发工具。 And at the end I found a nuget that is https://github.com/ToCSharp/AsyncChromeDriver You can try to look at.而且最后我发现了一个nuget 就是https://github.com/ToCSharp/AsyncChromeDriver可以试试看。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.