ElementNotInteractableException
ElementNotInteractableException: Causes and Fixes
Fix Selenium ElementNotInteractableException (ElementNotInteractableError in JS): hidden elements, duplicate matches, zero-size inputs and custom controls.
| Java | org.openqa.selenium.ElementNotInteractableException |
|---|---|
| Python | selenium.common.exceptions.ElementNotInteractableException |
| JavaScript | ElementNotInteractableError |
| C# | OpenQA.Selenium.ElementNotInteractableException |
What the error means
The element exists in the DOM (so you did not get NoSuchElementException), but the browser decided a user could not interact with it. Typical reasons: it is not rendered (display: none, visibility: hidden), it has zero width or height, it cannot be scrolled into view, or it is not the kind of element that accepts the action.
Compare this with ElementClickInterceptedException: there the element is visible but covered by something else. Here the element itself is the problem.
What it looks like
// Javaorg.openqa.selenium.ElementNotInteractableException: element not interactable (Session info: chrome=131.0.6778.86)Build info: version: '4.52.0' at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:...)# Pythonselenium.common.exceptions.ElementNotInteractableException: Message: element not interactable (Session info: chrome=131.0.6778.86)// JavaScript (selenium-webdriver)ElementNotInteractableError: element not interactable (Session info: chrome=131.0.6778.86)// C#OpenQA.Selenium.ElementNotInteractableException : element not interactable (Session info: chrome=131.0.6778.86)Firefox is more specific: Element <input id="email" type="email"> could not be scrolled into view or Element <input type="file"> is not reachable by keyboard. Chrome sometimes adds element has zero size.
Common causes
- Your locator matches a hidden duplicate. Responsive sites often render two copies of a control (desktop and mobile) and hide one.
findElementreturns the first match in document order, which may be the hidden one. - The element is not visible yet. It is in the DOM but still hidden, for example inside a collapsed accordion, a closed dropdown, or a modal that has not finished opening.
- A custom-styled control hides the real input. Checkboxes, radios, toggles and file inputs are often
opacity: 0or positioned off-screen, with a styledlabelorspanon top. - The element has zero size. An empty container, a wrapper
divinstead of the actual input, or a field collapsed by CSS. - You targeted a non-interactive element.
sendKeyson adivthat is notcontenteditable, or on the wrapper around a rich text editor.
How to fix it
Your locator matches a hidden duplicate
Count the matches. If there are two or more, make the locator specific to the visible one, or filter by visibility.
List<WebElement> matches = driver.findElements(By.cssSelector("button.search"));System.out.println("matches: " + matches.size());
WebElement visible = matches.stream() .filter(WebElement::isDisplayed) .findFirst() .orElseThrow(() -> new IllegalStateException("no visible search button"));visible.click();matches = driver.find_elements(By.CSS_SELECTOR, "button.search")print("matches:", len(matches))
visible = next((e for e in matches if e.is_displayed()), None)if visible is None: raise AssertionError("no visible search button")visible.click()const matches = await driver.findElements(By.css('button.search'));console.log('matches:', matches.length);
let visible = null;for (const el of matches) {if (await el.isDisplayed()) { visible = el; break; }}if (!visible) throw new Error('no visible search button');await visible.click();var matches = driver.FindElements(By.CssSelector("button.search"));Console.WriteLine("matches: " + matches.Count);
IWebElement visible = matches.FirstOrDefault(e => e.Displayed) ?? throw new InvalidOperationException("no visible search button");visible.Click();Better still, scope the locator to the container that is visible at your window size, for example header.desktop button.search, and pin the window size so the same copy is always visible.
The element is not visible yet
Open whatever reveals it (the accordion, the menu) and wait for visibility before acting.
driver.findElement(By.cssSelector("button[aria-controls='shipping']")).click();WebElement postcode = new WebDriverWait(driver, Duration.ofSeconds(10)) .until(ExpectedConditions.visibilityOfElementLocated(By.id("postcode")));postcode.sendKeys("SW1A 1AA");driver.find_element(By.CSS_SELECTOR, "button[aria-controls='shipping']").click()postcode = WebDriverWait(driver, 10).until( EC.visibility_of_element_located((By.ID, "postcode")))postcode.send_keys("SW1A 1AA")await driver.findElement(By.css("button[aria-controls='shipping']")).click();const postcode = await driver.findElement(By.id('postcode'));await driver.wait(until.elementIsVisible(postcode), 10000);await postcode.sendKeys('SW1A 1AA');driver.FindElement(By.CssSelector("button[aria-controls='shipping']")).Click();IWebElement postcode = new WebDriverWait(driver, TimeSpan.FromSeconds(10)) .Until(d => { var e = d.FindElement(By.Id("postcode")); return e.Displayed ? e : null; });postcode.SendKeys("SW1A 1AA");A custom-styled control hides the real input
Click what the user clicks: the visible label or styled wrapper. Then assert on the real input’s state.
driver.findElement(By.cssSelector("label[for='terms']")).click();boolean checked = driver.findElement(By.id("terms")).isSelected();driver.find_element(By.CSS_SELECTOR, "label[for='terms']").click()checked = driver.find_element(By.ID, "terms").is_selected()await driver.findElement(By.css("label[for='terms']")).click();const checked = await driver.findElement(By.id('terms')).isSelected();driver.FindElement(By.CssSelector("label[for='terms']")).Click();bool isChecked = driver.FindElement(By.Id("terms")).Selected;File inputs are the exception. A hidden input type="file" still accepts sendKeys with an absolute file path in Chrome and Edge, because file upload is special-cased. Firefox is stricter and may report the input as not reachable by keyboard; in that case, make it visible with a small script (set style.display = 'block') before calling sendKeys. The file uploads lesson covers both cases. Never click the visible “Browse” button: that opens a native OS dialog that WebDriver cannot control.
The element has zero size
Inspect the element in DevTools and look at its box model. If your locator points at a wrapper div with zero height, move the locator to the real input, button or a inside it. If the element is legitimately collapsed, trigger whatever expands it first.
You targeted a non-interactive element
For rich text editors (TinyMCE, CKEditor, Quill), find the contenteditable element, which may be inside an iframe, and send keys to that. For custom dropdowns built from divs, click the trigger and then click the option, rather than using Select.
How to prevent it
- Check locator uniqueness in DevTools as part of writing every locator. One match is the goal.
- Wait for visibility, not just presence, before interacting.
- Fix the window size in your driver setup so responsive duplicates resolve the same way every run.
- Interact with controls the way users do (labels, visible triggers), and assert on the underlying state.
- Avoid JavaScript
valueassignment as a workaround. It skips the input events frameworks listen for, so the form often ignores the value.
Related errors
- ElementClickInterceptedException: the element is visible but something is on top of it.
- NoSuchElementException: the element is not in the DOM at all.
- InvalidArgumentException: for file uploads, the path you sent does not exist on the browser’s machine.
- MoveTargetOutOfBoundsException: the Actions API version of “cannot reach this element”.
Go deeper
- Click and Type Learn the fundamental Selenium interactions: clicking elements and typing text into input fields.
- Forms and Inputs Master form interactions including text fields, checkboxes, radio buttons, and form submission.
- Expected Conditions Use built-in expected conditions for common wait scenarios like visibility, clickability, and text presence.
- File Uploads Handle file uploads in Selenium tests by interacting with file input elements.