Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElementNotInteractableException: element not interactable: element has zero size appears since upgrade to chromedriver 83

I use the following docker image to run my cucumber tests:

https://hub.docker.com/r/selenium/standalone-chrome/

Unfortunately, starting from today it seems that whenever I run my tests I get the errors below. They appear at the start of each test. It does not matter what I do on the page.

**13:38:26 [exec] org.openqa.selenium.ElementNotInteractableException: element not interactable: element has zero size

13:38:26 [exec] (Session info: chrome=83.0.4103.61)**

I did some digging and I noticed the chromedriver version was updated from 81 to 83. I managed to fix this issue by using an older docker image from that docker hub link which has chromedriver 81. But if I attempt to use chromedriver 83 again it will not work.

Has anyone else encountered this? Is there a new chrome option I need to add because of the update?

like image 913
Robert Curetean Avatar asked May 25 '20 13:05

Robert Curetean


People also ask

How do you fix the element not Interactable exception?

To fix this, we can either apply explicit wait so that the webdriver waits for the expected condition - invisibilityOfElementLocated of the overlaying webelement. Or, we can apply the expected condition - elementToBeClickable on the webelement that we want to interact with.

Is not reachable by keyboard?

Element is not reachable by keyboard in plain words means that the element can't be reached using the keyboard, which means you won't physically interact with it even. There are different approaches to address this issue.


3 Answers

The root cause of that issue is that Chrome doesn't scroll to the element outside of the viewport. Instead of it, Chrome tries to click on it outside of the viewing area. That's why the issue appears. It is definitely an issue with Chrome 83 because I didn't face it on Chrome 81.

Moreover, I have no such issue on Windows machine, it reproduced only on Linux (I'm using selenoid docker images).

Solution with a click via JS is not the best option, because via JS you can click anywhere even for unclickable elements (e.g. overlapped by other objects). It's an unsafe operation.

Instead of this, I would suggest scrolling to the element before click and after native click(); it will work just perfectly.

JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].scrollIntoView(true);", element);    
element.click();
like image 114
kalumpiwarra Avatar answered Sep 25 '22 13:09

kalumpiwarra


I got around this by using the --window-size argument when I'm using headless chrome. E.g. chrome --headless --window-size=400,800.

I do not know what changed or why this is a sufficient workaround.

like image 6
John Avatar answered Sep 24 '22 13:09

John


I'm getting this error also, i did some digging, i found that the element size contains 0, for example an element of size 200 x 0 will get you this error if you want to click on it. This is not a docker only error, i'm getting it on local chrome 83.

Try clicking on element using the Javascript Executor:

JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);
like image 6
Wael.B Avatar answered Sep 24 '22 13:09

Wael.B