【发布时间】:2021-12-25 04:44:25
【问题描述】:
这是我的按钮在 HTML 中的代码:
<button type="submit" class="btn btn-secondary" id="single_button618eda460b64617" title="">Re-attempt quiz</button>
我为许多其他组件定义的类和id 总是以single_button 开头。
但结尾是随机字符。并且是唯一以这个前缀开头的。
我如何使用button=driver.find_element_by_id(),但对于第一个single_button?
【问题讨论】:
-
driver.find_element_by_xpath("//button[contains(@id, 'single_button')]")
标签: python selenium xpath css-selectors findelement