Selenium web driver cannot click a button while element is visible and clickable, throws org.openqa.selenium.ElementNotInteractableException Selenium web driver cannot click a button while element is visible and clickable, throws org.openqa.selenium.ElementNotInteractableException selenium selenium

Selenium web driver cannot click a button while element is visible and clickable, throws org.openqa.selenium.ElementNotInteractableException


Use javascriptExecutor to click the element by embedding javascript. By using javascript executor we can run the javascript on the driver.

WebElement element = driver.findElement(By.id("id-home_prevButton");((JavascriptExecutor)driver).executeScript("arguments[0].click();", element);


I also had a similar problem which was fixed by:

String id = element.getAttribute("id");((JavascriptExecutor)driver).executeScript("$('#id').click();");


With Selenium Advanced User Interaction API mentioned e.g. here: I could fix this issue. Modified selenium code is as follows:

import org.openqa.selenium.support.ui.WebDriverWaitval waitPrevButton = new WebDriverWait(driver, 20)val prevButton = driver.findElement(By.id("id-home_prevButton"))log.debug(wEPrint("prevButton",prevButton))waitPrevButton.until(ExpectedConditions.visibilityOfElementLocated(By.id("id-home_prevButton")))log.debug("id-home_prevButton.click")//prevButton.click()//prevButton.sendKeys(Keys.RETURN)//prevButton.sendKeys(Keys.ENTER)new Actions(driver).moveToElement(prevButton).click().perform()

This fixes the issue but I would still like to know the reason for the ElementNotInteractableException and why selenium complained "Element is not visible" after successfull visibilityOfElementLocated test. Any ideas?