【发布时间】:2021-12-17 18:48:21
【问题描述】:
我在单击 second 按钮时遇到问题,因为我收到了以下错误消息:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
html 按钮:
<button class="btn btn-primary btn-fab" type="button"
<span class="mdi mdi-plus" aria-hidden="true"></span>
<span class="sr-only">+</span>
<button class="btn btn-primary btn-fab" type="button"
<span class="mdi mdi-minus" aria-hidden="true"></span>
<span class="sr-only">-</span>
我的代码:
button = driver.find_element_by_css_selector('div.amount-control > button.btn.btn-primary.btn-fab > span.mdi.mdi-plus')
button.click()
我的代码所做的是定位 second 按钮,问题是我必须定位 <span class="mdi mdi-plus" aria-hidden="true"></span> 来区分这两个按钮,但我认为我必须点击 <button class="btn btn-primary btn-fab" type="button" 而不是跨度,因为它不是可交互。
找到跨度后如何单击<button> 而不是跨度。
【问题讨论】:
-
认为我在您的上一篇文章中为此提供了 xpath。