python Selenium 使用 报错AttributeError: ‘WebDriver‘ object has no attribute ‘find_element_by_xpath‘

参考

问题定位

根本问题是 本机的Selenium包将方法给移除了

最新版的方法对应旧版:

python Selenium 使用 报错AttributeError: ‘WebDriver‘ object has no attribute ‘find_element_by_xpath‘_第1张图片

解决方法

1、本机包降版本直接使用源代码(适合代码量大且复杂的)

pip install selenium==4.2.0 --force-reinstall

2、方法修改为最新的版本对照上图即可

代码量小可以重写

你可能感兴趣的:(Python,python)