【问题标题】:Selenium element not interactable button (Python, Windows, Chromedriver)Selenium 元素不可交互按钮(Python、Windows、Chromedriver)
【发布时间】:2020-10-12 17:29:50
【问题描述】:

错误:引发异常类(消息、屏幕、堆栈跟踪) selenium.common.exceptions.ElementNotInteractableException:消息:元素不可交互 (会话信息:chrome=86.0.4240.75)

我的代码:driver.find_element_by_xpath('//button[contains(text(),"Buy Now")]').click()

html:https://i.stack.imgur.com/h0wGd.png

【问题讨论】:

    标签: python windows selenium


    【解决方案1】:

    由于我们没有完整的HTML 页面来查找准确的xpath,并且我们有代码的小屏幕截图,您可以尝试使用不同的xpath 技术来查找元素。

    //button[@class='button bits' and contains(., 'Buy Now')]
    

    然后,您可以使用以下选项之一获取该元素并单击它。

    选项 1

    driver.find_element(By.XPATH, "//button[@class='button bits' and contains(., 'Buy Now')]").click()
    

    选项 2

    driver.find_element(By.XPATH, "//button[@class='button bits' and contains(text(), 'Buy Now')]").click()
    

    【讨论】:

      【解决方案2】:

      根据 selenium 文档,该错误发生在以下情况:

      "Thrown when an element is present in the DOM but interactions
      with that element will hit another element do to paint order"
      

      确保您的元素是唯一标识并使用等待。如果还不够,请通过 JavaScript 执行点击操作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-03-08
        • 2021-12-16
        • 1970-01-01
        • 1970-01-01
        • 2021-08-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多