Fixing Selenium and Python error – ElementNotInteractableException element not interactable

Selenium and Python error – ElementNotInteractableException element not interactable is an error which occurs when Selenium cannot find the element you want to click for example.

In this article I am going to explain why the error is happening and how to install Selenium properly without getting the error again. Also we are going to check out other solutions that may work for your particular case.

Exploring the Error : Selenium and Python error – ElementNotInteractableException element not interactable

This is an error which occurs when Selenium cannot find the element you want to click for example.

The error message should look like the message bellow. Make sure you are not dealing with another error.

                                                                       #
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
                                                                       #

In the sections bellow we will explain the root of the error more and propose a set of possible fixes and options

Solution : use WebDriverWait with Selenium or use the correct css selector

This error might occur in Selenium when Selenium is not able to find an element or click it.

There a loot of possibilities why that is happening, maybe you are using the wrong selector or another element is standing in Selenium’s way and preventing it from selecting and clicking the element for example.

The best solution is to use WebDriverWait.

WebDriverWait is an explicit wait method, explicit waits are linked to a web element and enable you to wait for a certain condition to occur before continuing with the execution of the code.

This is how to use WebDriverWait for example in order to automatically FILL the Email field within a Login section of a website with a particular email address.

                                                                       #
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,
 "//div[@class='title login_title' and text()='Login']
//following::div[1]//input[@class='text header_login_text_box
 ignore_interaction']"))).send_keys("myemail@email.com")
                                                                       #

Before you use the line above you should get the URL of the page you want. www.twitter.com for Example.

                                                                       #
driver.get("https://www.twitter.com/")
                                                                       #

We are using one css selector and another xpath selector in the example bellow, the page we are dealing with is the main page of the quora website

If you are trying to get the element using an xpath selector and it does not work try using a css selector instead.

Summing-up

That’s it fellow developers, this is the end of this guide, I hope you found this useful in solving your particular issue, if you have the means and want to help, please support our work on our Kofi account, you do not have to, but you can donate if you want.

Thank you, keep coding and cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/