Selenium – Element not interactable

Question:

Needing help on this problem. All solutions/suggestions I have researched do not fix it.

Trying to click a button with Selenium. Keep getting these errors.
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable: [object HTMLButtonElement] has no size and location
and selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

I am not understanding why this element is 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()

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

I have tried WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="ppp"]/div/div[2]/div[2]/div[2]/button'))) but this times out. Element never becomes clickable.

I have tried using the full xpath.

I have tried disabling extensions/maximize window driver options.

The element is not in a frame or anything. It lies in a div that lies in the body.
The element is clickable within Chrome’s console.

Any information/suggestions would be helpful.
Thanks.

Asked By: JOhn

||

Answers:

The button you are trying to click is hidden, not clickable even with JavaScript executor.
You can start video on that page clicking on

driver.find_element_by_css_selector('div.player-poster.clickable').click()

or

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

No need to use ActionChains(driver).move_to_element etc.
Just a simple click.
Just don’t forget setting

driver.implicitly_wait(10)

Or using an explicitly wait of expected conditions to make page loaded before accessing the element.

Answered By: Prophet

Using full XPath solved this problem for me.

Answered By: kraftwerk