【问题标题】:Selenium & Python: Button not interactable; href="javascript:void(0);" onclick attributeSelenium 和 Python:按钮不可交互; href="javascript:void(0);" onclick 属性
【发布时间】:2021-03-11 01:05:55
【问题描述】:

我正在尝试单击此按钮

下一个 >>

我的代码是

next_page = driver.find_element_by_xpath("//a[contains(text(), 'Next')]")
next_page.click()

我也尝试过使用类名和 onclick 属性名,但它们也不起作用。

代码返回错误为 ElementNotInteractableException:消息:元素不可交互(会话信息:chrome=88.0.4324.192)。

【问题讨论】:

  • 分享按钮的 HTML。它可能被设置为禁用。

标签: python html selenium


【解决方案1】:

按钮可能被隐藏并且无法直接访问。也许试试这个:

from selenium.webdriver.common.action_chains import ActionChains

next_page = driver.find_element_by_xpath("//a[contains(text(), 'Next')]")
driver.implicitly_wait(10)
ActionChains(driver).move_to_element(next_page).click(next_page).perform()

How do you fix the "element not interactable" exception?

【讨论】:

    猜你喜欢
    • 2016-06-08
    • 1970-01-01
    • 1970-01-01
    • 2011-04-09
    • 2013-04-24
    • 1970-01-01
    • 1970-01-01
    • 2011-10-21
    • 1970-01-01
    相关资源
    最近更新 更多