dockerselenium-chromedriver

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?


Solution

  • 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();