Skip to content
Advertisement

Error “Message: element not interactable” is displayed when I try upload a file with selenium python

When I executing the test case in console an error is displayed ->

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

I add the location of the file but script be broken

My code

driver.find_element(By.XPATH, '/html/body/div[1]/section/section/main/div/div/div/div/form/div[4]').send_keys('E:DescargasSupport-GPSD-945.zip')

Any solution?

Advertisement

Answer

As the error message says, the element you’re locating isn’t interactable. That means that Selenium is looking at the element and has decided it’s not something that can be clicked, typed into, etc.

This usually happens for one of two reasons:

  1. The page/element hasn’t finished loading or the DOM is in flux
  2. The element truely isn’t interactable

I think you’re having problem two, but just in case, I’m going to leave suggestions for both.


If the Element hasn’t finished loading

If the problem is the first case, you should add a wait to ensure the page is fully loaded and the DOM has settled down. Best practise is usually to add a wait for the appearance of an element that ensures the page has loaded, rather then waiting a static amount of seconds…

But a static wait is OK while debugging, IMO.


If the element truely isn’t interactable

It looks like you’re selecting a div, not an input. That is, you’re trying to send text to part of the page structure, rather then the form element itself. I’m guessing you’ve generated this XPath using a tool?

The best solution here is to adjust your selector so it points to the form element. If the element has a unique ID or class name, use a CSS selector with that. (If it doesn’t, tell your development team off for not writing the front end in a more testable way).

If the element doesn’t have an ID or class name, you’ll need to edit your XPath to select the input, rather then the div. Without seeing your code I can only guess, but adding:

/input

to the end of the selector might do it.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement