小编Ben*_*het的帖子

Selenium Chromedriver:禁用 w3c 时,“dict”对象没有 find_element() 方法的属性“click”

刚刚开始尝试 selenium 和 chromedriver,我在特定配置中出现错误。当我调用一个或多个方法时

,我总是得到 : 。'dict' object has no attribute 'click'find_element()find_element_by_*

我发现该行:

options.add_experimental_option('w3c', False)
Run Code Online (Sandbox Code Playgroud)

引起了这个问题,但不明白为什么以及如何解决这个问题。

问题:
- 这是正常行为吗?
- 关于如何解决这个问题的想法?

信息:我禁用了 w3c,以便能够检索性能日志(网络)的状态代码。

这是我制作的独立测试代码:

import os
import json

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

# Get Chrome Driver Fullpath
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
DRIVER_FULLPATH = os.path.join(PROJECT_ROOT, "chromedriver")


# Options
options = Options()

## Enable headless
options.headless = False
# Disable w3c to be able …
Run Code Online (Sandbox Code Playgroud)

python selenium python-3.x selenium-chromedriver selenium-webdriver

4
推荐指数
1
解决办法
1824
查看次数