简体   繁体   English

AttributeError: 'WebDriver' object 没有属性 'execute_cdp_cmd'

[英]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.

相关问题 Python selenium 使用 execute_cdp_cmd 访问 chrome 开发工具 | 确定哪个 stylesheetId 属于哪个样式表 - Python selenium accessing chrome dev tools with execute_cdp_cmd | Determine which stylesheetId belongs to which stylesheet AttributeError:对象没有属性'execute' - AttributeError: object has no attribute 'execute' djangocms: AttributeError: 'FileNotFoundError' 对象没有属性 'cmd' - djangocms: AttributeError: 'FileNotFoundError' object has no attribute 'cmd' AttributeError:Selenium Webdriver中的python对象没有属性 - AttributeError: object has no attribute in python in selenium webdriver AttributeError: 'WebDriver' object 没有属性 'driver' - AttributeError: 'WebDriver' object has no attribute 'driver' AttributeError问题:'WebDriver'对象没有属性'manage' - Issue with AttributeError: 'WebDriver' object has no attribute 'manage' AttributeError:'模块'对象没有属性'webdriver' - AttributeError: 'module' object has no attribute 'webdriver' AttributeError: 'WebDriver' object 没有属性 'findElement - AttributeError: 'WebDriver' object has no attribute 'findElement AttributeError:'str'对象没有属性'execute' - AttributeError: 'str' object has no attribute 'execute' 发生异常:AttributeError 'WebDriver' object has no attribute 'link' - Exception has occurred: AttributeError 'WebDriver' object has no attribute 'link'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM