Selenium - 元素不可交互

Selenium - Element not interactable

在这个问题上需要帮助。我研究的solutions/suggestions都没有修复

正在尝试使用 Selenium 单击按钮。不断收到这些错误。 selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable: [object HTMLButtonElement] has no size and locationselenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

我不明白为什么这个元素不可交互。

    play_button = driver.find_element_by_xpath('//*[@id="ppp"]/div/div[2]/div[2]/div[2]/button')
    driver.implicitly_wait(10)
    ActionChains(driver).move_to_element(play_button).click(play_button).perform()

打印时play_button = <selenium.webdriver.remote.webelement.WebElement (session="ca50b37ee2e4b194b2ad5305e254079f", element="78e35dc3-fef8-4082-a6e4-0a92dfbf2ec6")>

我试过 WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="ppp"]/div/div[2]/div[2]/div[2]/button'))) 但是这次超时了。元素永远不会变成可点击的。

我试过使用完整的 xpath。

我试过禁用 extensions/maximize window driver 选项。

该元素不在框架或其他任何地方。它位于 div 中,位于 body 中。 该元素可在 Chrome 的控制台中单击。

任何 information/suggestions 都会有所帮助。 谢谢。

您尝试点击的按钮已隐藏,即使使用 JavaScript 执行程序也无法点击。
您可以在该页面上点击

开始播放视频
driver.find_element_by_css_selector('div.player-poster.clickable').click()

driver.find_element_by_css_selector('div.play-wrapper').click()

无需使用ActionChains(driver).move_to_element
只需点击一下。
只是不要忘记设置

driver.implicitly_wait(10)

或者使用显式等待预期条件来使页面在访问元素之前加载。