小工具知识网

当前位置: 首页 > 行业知识 > selenium-4.18.1 报错AttributeError: ‘WebDriver‘ object has no attribute ‘find

行业知识

selenium-4.18.1 报错AttributeError: ‘WebDriver‘ object has no attribute ‘find

2026-11-14 00:20:43 来源:互联网转载

在4.18.1版本下的selenium运行语句:

elements = browser.find_elements_by_css_selector('.item .name')

报错:

AttributeError: 'WebDriver' object has no attribute 'find_elements_by_css

解决方法:

查看selenium-4.18.1文档,可以看到

方法一:根据文档,可通过find_element(By.CSS_SELECTOR,'#fname')来使用CSS选择器功能,只不过find_element只能返回第一个符合的节点内容,想要全部符合的节点内容可使用find_elements(By.CSS_SELECTOR,'#fname')

方法二:卸载当前版本selenium,下载能够使用find_elements_by_css_selector()方法的的selenium版本。

上一篇:最新网站快照更新一览掌握最新动态,轻松畅游网络世界!

下一篇:揭秘Mars源码核心,一探究竟,吸引你的目光探索之旅