python - Python 硒 (html) 复选框
问题描述
我尝试使用普通命令单击此按钮,.click()
但它不起作用
并且在手动点击它之后,类从这个“ glyphsSpriteCircle__outline__24__grey_2 u-__7
”变为这个“ glyphsSpriteCircle_check__filled__24__blue_5 u-__7
”怎么办?
<button class="dCJp8">
<span aria-label="Toggle selection" class="glyphsSpriteCircle__outline__24__grey_2 u-__7"></span>
</button>
解决方案
你有一个动态元素。
您需要使用不变的部分,例如:
或者您可以对静态的部分使用正则表达式,例如
driver.find_element_by_xpath("//span[contains(@class,'glyphsSpriteCircle')]")
请参阅https://www.tutorialspoint.com/how-to-use-regular-expressions-in-xpath-in-selenium-with-python
推荐阅读
- json - 如何在 ExtJS 中加入模型?
- python - 通过视频通话进行手语翻译不会产生同步翻译
- python - Discord.py TypeError:“int”类型的参数不是可迭代错误
- javascript - 动态输入计算器
- android - 使用 AuroraStore 代码,它如何获取“库”(已安装应用程序的历史记录),以及如何获取它们的安装时间?
- php - 未处理的异常:FormatException:意外字符(在字符 1 处)颤振
- c# - (C#) 从 TextBox WinForms 的删除字符中获取索引
- laravel - Laravel 8:将工厂属性传递给子关系
- node.js - 共享主机上的 500 内部服务器错误
- python - Pygame - 生成随机对象错误