python - 问题“ driver.find_element_by_xpath("//div[@class='example']"
问题描述
这几天我一直在遇到这个问题。我使用 Pycharm 和 Python:
UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead")
问候
解决方案
尝试以下...
首先,导入By如下:from selenium.webdriver.common.by import By
然后,如果您尝试通过 xpath 查找元素,例如,请替换:
find_elements_by_xpath("[***whatever the xpath is***]")
和:
driver.find_element(By.XPATH, "[***whatever the xpath is***]")
有关调用元素的各种方法的示例,请参阅Selenium with Python 参考网站
推荐阅读
- python - 具有基于列的条件的滚动窗口?
- nginx - Nginx 是否可以在不重新加载 Nginx 的情况下自动更新上游服务器的详细信息
- visual-studio-code - 未找到 VS Code Microsoft Edge 开发人员工具
- ios - “zsh:找不到命令:expo”,尽管它已安装
- c# - 展平锯齿状数组和地图索引
- swift - 动画渐变视图在预览画布中工作,但在设备上出现奇怪的行为
- javascript - 单击后如何退出 Mappa/Leaflet div
- typescript - 用 TypeScript 编写的 Babel 插件参数的类型是什么?
- c# - 当按下超过 1 个键时如何使 e.Handled = true。Windows 窗体
- mysql - MySQL Find_In_Set 语句帮助