AttributeError: ‘WebDriver‘ object has no attribute ‘find_elements_by_xpath‘

问题描述

使用selenium时,抛出下面的异常,先前的代码是可以工作的,换了环境,或者重新安装了执行环境。

AttributeError: 'WebDriver' object has no attribute 'find_elements_by_xpath'

问题原因

selenium 4.2后,方法已废弃。
查看当前版本

pip list | grep sele
selenium            4.17.2

[notice] A new release of pip is available: 23.2.1 -> 24.0
[notice] To update, run: python.exe -m pip install --upgrade pip

解决方案

使用新的方法,或者降级 pip install selenium==4.2.0 --force-reinstall

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-09 08:04:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-09 08:04:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-02-09 08:04:01       87 阅读
  4. Python语言-面向对象

    2024-02-09 08:04:01       96 阅读

热门阅读

  1. OpenHarmony轻量级驱动开发

    2024-02-09 08:04:01       51 阅读
  2. re:从0开始的CSS学习之路 8. 浏览器默认样式

    2024-02-09 08:04:01       51 阅读
  3. Solidity 045 LibraryClient

    2024-02-09 08:04:01       46 阅读
  4. 2024.2.8日总结(小程序开发5)

    2024-02-09 08:04:01       51 阅读
  5. 【从零开始学设计模式】第七章_适配器模式

    2024-02-09 08:04:01       58 阅读