Skip to content Skip to sidebar Skip to footer

InvalidElementStateException Invalid Element State: Element Must Be User-editable In Order To Clear It" Error While Sending Text With Selenium Python

I have an input HTML element like this in Django When I want to find and clear it elm_input = self.wait.until(EC.presence_of_ele

Solution 1:

This error message...

InvalidElementStateException invalid element state: Element must be user-editable in order to clear it"

...implies that the WebDriver instance was unable to clear the existing contents of the element.


A bit more of the outerHTML of the element would have helped us to analyze the issue in a better way. However you need to take care of a couple of things as follows:

  • While sending a character sequence instead of using presence_of_element_located() you have to induce WebDriverWait for the element_to_be_clickable().
  • Ensure the Locator Strategy uniquely identifies the WebElement and you can use either of the following Locator Strategies:

    • Using CSS_SELECTOR:

      elm_input = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#id[type='number'][maxlength='50']")))
      elm_input.clear()
      elm_input.send_keys("1234567890")
      
    • Using XPATH:

      elm_input = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='id' and @type='number'][@maxlength='50']")))
      elm_input.clear()
      elm_input.send_keys("1234567890")       
      
    • Note : You have to add the following imports :

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

Reference

You can find a relevant discussion in:


Post a Comment for "InvalidElementStateException Invalid Element State: Element Must Be User-editable In Order To Clear It" Error While Sending Text With Selenium Python"