ElementNotInteractableException: Message: element not interactable error sending text in search field using Selenium Python

This error message…

ElementNotInteractableException: Message: element not interactable

…implies that the WebElement with whom you are trying to interact isn’t interactable (isn’t in interactable state) at that point of time.

The two(2) main reasons for this error are:

  • Either you are trying to interact with a wrong/mistaken element.
  • Or you are invoking click() too early even before the element turns clickable / interactable.

To send a character sequence with in the search field you you have to induce WebDriverWait for the element_to_be_clickable() and you can use the following Locator Strategies:

Code Block:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

options = webdriver.ChromeOptions() 
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
driver.get("https://thelubricantoracle.castrol.com/industrial/en-DE")
WebDriverWait(driver, 20).until(lambda driver: driver.execute_script('return document.readyState') == 'complete')
time.sleep(3)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@class="button primary" and contains(@id, 'termsPopup_lbConfirm')]"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='search-init']"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class="search"]"))).send_keys("Example")

Browser Snapshot:

castrol


Reference

You can find a couple of relevant detailed discussions in:

Leave a Comment