python - 如何使用 Python Selenium 找出网站中存在的特定元素?
问题描述
解决方案
这将清楚地指示页面上是否有任何元素在其任何属性中包含“C10”。
elements = driver.find_elements_by_xpath("//*[contains(.,'C10')]")
if(elements):
print("Elements containing C10 found on the page")
//*[contains(.,'C10')]
将匹配任何属性中包含“C10”的任何元素。
driver.find_elements_by_xpath("//*[contains(.,'C10')]")
将返回匹配的 Web 元素列表。如果找到这样的元素 - 列表将是非空的,非空列表被解释为True
在 python 中。
推荐阅读
- integration-testing - 故障安全不适用于wiremock集成测试
- python - TypeError:范围索引必须是整数或切片,而不是元组
- python - 在 Python 中读取文件并将其修改为副本
- javascript - 在页面上的特定点开始滚动指示器
- javascript - 如何使用 JavaScript 访问 html 元素中的数据
- jenkins-pipeline - 詹金斯,詹金斯文件,DevOps,
- c# - 如何实现 Struct 用作字典键
- python - Keras 神经网络:ValueError - 输入形状错误
- android - 添加 Firestore 和 MultiDex 导致我的 Android 应用程序崩溃
- python - 基于相机高度计算由广角/短焦距镜头引起的每像素厘米失真