How to resolve exception Element Not Interactable Exception in Selenium?

We can resolve the exception – ElementNotInteractableException with Selenium webdriver. This exception is thrown if a webelement exists in DOM but cannot be accessed. The below image shows an example of such an exception.

If a specific webelement is overspread by another webelement we normally get this 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. To resolve a permanent overlay, we have to use the JavaScript Executor to perform the click action. Selenium utilizes the executeScript method to run JavaScript commands.


WebDriverWait wait= (new WebDriverWait(driver, 5));
wait.until(ExpectedConditions . elementToBeClickable ("element id")));
//alternate solution
wait.until(ExpectedConditions. invisibilityOfElementLocated("overlay element id")));
//fix with JavaScript executor
WebElement m = driver.findElement("element id"));
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("arguments[0].click();", m);


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.JavascriptExecutor;
public class InteractableExceptResolve{
   public static void main(String[] args) {
      System.setProperty("", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      //launch URL
      //identify element
      WebElement m = driver.findElement(By.xpath("//input[@id='persistent']"));
      //JavascriptExecutor to click element
      JavascriptExecutor jse = (JavascriptExecutor) driver;
      jse.executeScript("arguments[0].click();", m);
      boolean b = m.isSelected();
      if (b) {
         System.out.println("Checkbox is not checked");
      }else {
         System.out.println("Checkbox is checked");