简体   繁体   中英

Python Selenium, Input field returns an ElementNotInteractableException even though element is interactable

Problem:

After pressing a button on the website, a popup window opens up which contains multiple input fields which are generated by react. Most of these are accessible. However, one of them is not and returns an ElementNotInteractableException error. I have tried the most common solutions but those do not work.

The interesting part is that when the element is accessed manually from the front end, it can be interacted with. The element also is shown normally in a screenshot which is taken upon an exception being thrown

Solutions tried:

  • Increase implicit wait until 1 minute,
  • Add explicit wait untill 1 minute
  • Use different finding methods for the element
  • Reorder test to see if other elements influence it (all possible orders have failed)

Code block on which the error occurs:

    #this input element is next to it in the same parent element
    dropdownparent = elems[2].find_element_by_xpath(".//div[@role='combobox']")
    dropdowninput = dropdownparent.find_element_by_css_selector("input")
    f.inputtext(dropdowninput, "Coulance", True )
    #reobtain the parent items to avoid a stale element reference error
    modal = self.driver.find_element_by_class_name("component-window")
    body = modal.find_element_by_class_name("body")
    elems = body.find_elements_by_xpath("./div")
    required = elems[2].find_elements_by_class_name("required")
    inputparent = required[1].find_element_by_class_name("input")
    input = inputparent.find_element_by_css_selector("input")
    #error occurs on next line
    f.inputtext(input, "200")

Error log:

https://pastebin.com/ihqCvjfj

its long but its a very standard elementnotaccessible

Any suggestions would be appreciated, I will update the solutions tried section whenever I try something

Element not interactable comes when the element is out of clickable area or some other element is covering up that element. You can try by scrolling the page to an element or you can set input value by executing javascript, something like this:

element = inputparent.find_element_by_css_selector("input")
driver.execute_script("""arguments[0].value = arguments[1];""", element, "some input value") 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM