Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selenium invalid element state: Element is not currently interactable and may not be manipulated

Tags:

selenium

I have this issue with selenium; I cannot find i textinput : it always raises this exeception:

Element is not currently interactable and may not be manipulated

in this line:

Driver.FindElement(By.Id("ctl00")).Clear();

I try to put waiting like this:

Waiting.Until(driver =>(By.Id("ctl00")));

and

Waiting.Until(ExpectedConditions.ElementExists(By.Id("ctl00"))); 

but no luck.

like image 643
Kais Zwawi Avatar asked Aug 07 '14 08:08

Kais Zwawi


People also ask

How do you solve an invalid element State?

Solution for InvalidElementStateException in Selenium Webdriver. Always try to perform the required operation based on element state. If it is clickable element then perform click and if it supports type event then perform sendkeys. If the element is disabled then enable it first and then perform operations.

What is stale element exception?

A stale element reference exception is thrown in one of two cases, the first being more common than the second: The element has been deleted entirely. The element is no longer attached to the DOM.


4 Answers

If the exception gets thrown on Clear(), the element is most likely present on the page and the input in a readonly state.

like image 80
Daniel Kereama Avatar answered Oct 19 '22 21:10

Daniel Kereama


Try to validate XPath first as might be that targeting more than one element. Due to this, element not currently interactable and may not be manipulated.

I faced same issue and found solution with above as my XPath was locating multiple element which exists on DOM but not page.

Correct the element XPath, error will resolve automatically with adding webdriver wait.

like image 21
Himanshi Avatar answered Oct 19 '22 21:10

Himanshi


I hit the same error, was also a bit confused, but resolved it using the below wait condition. The elementToBeClickable condition checks that the element is both visible and enabled. Perhaps visibility is enough, but Selenium throws an explicit ElementNotVisibleException, so I'm not sure why I wouldn't get that... Anyways, I opted to use a more robust wait condition, and it has worked well for me.

wait.until(ExpectedConditions.elementToBeClickable(By.id("myElementId"))).clear();
like image 37
The Gilbert Arenas Dagger Avatar answered Oct 19 '22 19:10

The Gilbert Arenas Dagger


This happens sometimes when element is not visible. It would happen even when element is visible also. Try using with different tags like xpath or etc.

You can check the element status using below script

driver.findElement(By.className("")).isEnabled()
like image 2
venu9955 Avatar answered Oct 19 '22 19:10

venu9955