报错了AttributeError: 'WebDriver' object has no attribute 'find_element_by_class_name'
时间: 2023-08-07 11:03:12 浏览: 311
回答: 报错AttributeError: 'WebDriver' object has no attribute 'find_element_by_class_name'是因为WebDriver对象没有find_element_by_class_name方法。\[3\]解决这个问题的方法是使用selenium的By模块来定位元素,具体的写法如下:
from selenium.webdriver.common.by import By
el = driver.find_element(By.CLASS_NAME, "class_name")
其中"class_name"是你要查找的元素的class属性值。通过这种方式,你可以成功定位到元素并解决报错问题。
#### 引用[.reference_title]
- *1* [报错 AttributeError: ‘WebDriver‘ object has no attribute ‘find_elements_by_xpath‘ 解决方法](https://blog.csdn.net/qq_52341947/article/details/127631533)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [Python报错AttributeError: ‘WebDriver‘ object has no attribute ‘find_element_by_xpath‘解决方法](https://blog.csdn.net/m0_52818006/article/details/126283288)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文