Skip to main content
SeleniumDecoded

ElementClickInterceptedException

ElementClickInterceptedException: Causes and Fixes

Fix Selenium ElementClickInterceptedException (ElementClickInterceptedError in JS): overlays, cookie banners, sticky headers and animations blocking your click.

Very common W3C: element click intercepted Verified against Selenium 4.52.0
Exception name by language
Java org.openqa.selenium.ElementClickInterceptedException
Python selenium.common.exceptions.ElementClickInterceptedException
JavaScript ElementClickInterceptedError
C# OpenQA.Selenium.ElementClickInterceptedException

What the error means

WebDriver clicks like a user. It scrolls the element into view, computes the centre point of the element, and checks which element is actually on top at that point. If a different element would receive the click (a modal backdrop, a cookie banner, a sticky header, a loading spinner), the driver refuses and throws “element click intercepted” rather than clicking the wrong thing.

This is a feature. A real user would also have clicked the overlay. The error is telling you that the page is not in the state your test assumes.

What it looks like

// Java
org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element <button id="submit" class="btn">...</button> is not clickable at point (412, 380). Other element would receive the click: <div class="modal-backdrop fade show"></div>
(Session info: chrome=131.0.6778.86)
# Python
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <button id="submit" class="btn">...</button> is not clickable at point (412, 380). Other element would receive the click: <div id="onetrust-banner-sdk">...</div>
// JavaScript (selenium-webdriver)
ElementClickInterceptedError: element click intercepted: Element <a href="/pricing">...</a> is not clickable at point (96, 22). Other element would receive the click: <header class="site-header sticky">...</header>
// C#
OpenQA.Selenium.ElementClickInterceptedException : element click intercepted: Element <button id="submit">...</button> is not clickable at point (412, 380). Other element would receive the click: <div class="spinner-overlay">...</div>

Firefox phrases it as Element <button id="submit"> is not clickable at point (412,380) because another element <div class="modal-backdrop"> obscures it.

Read the “Other element would receive the click” part. It names the culprit, and that tells you which fix you need.

Common causes

  1. A loading overlay or spinner is still covering the page after navigation or an XHR.
  2. A cookie consent banner, newsletter popup or chat widget sits over the content.
  3. A modal is opening or closing and its backdrop is still in the DOM during the CSS transition.
  4. A sticky header or footer covers the element after the driver scrolls it to the edge of the viewport.
  5. The element is still animating into position (slide-in menus, accordions), so the centre point lands on something else.
  6. The layout differs at the current window size, typically the small headless default, so elements overlap.

How to fix it

A loading overlay or spinner

Wait for the overlay to disappear, then wait for the target to be clickable.

Wait for the overlay to go, then click
Selenium 4 Stable
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15));
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".spinner-overlay")));
wait.until(ExpectedConditions.elementToBeClickable(By.id("submit"))).click();
wait = WebDriverWait(driver, 15)
wait.until(EC.invisibility_of_element_located((By.CSS_SELECTOR, ".spinner-overlay")))
wait.until(EC.element_to_be_clickable((By.ID, "submit"))).click()
const overlays = await driver.findElements(By.css('.spinner-overlay'));
if (overlays.length) {
await driver.wait(until.elementIsNotVisible(overlays[0]), 15000);
}
const submit = await driver.findElement(By.id('submit'));
await driver.wait(until.elementIsEnabled(submit), 15000);
await submit.click();
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(15));
wait.Until(d => d.FindElements(By.CssSelector(".spinner-overlay")).All(e => !e.Displayed));
wait.Until(d =>
{
var el = d.FindElement(By.Id("submit"));
return el.Displayed && el.Enabled ? el : null;
}).Click();

Note that elementToBeClickable checks visibility and enabled state; it does not check whether something is on top. That is why you must wait for the overlay explicitly. The wait for spinner recipe has a reusable version.

Dismiss it once, early, the way a user would. Better still, set the consent cookie before the first page load so the banner never appears. See the dismiss cookie banner recipe.

Dismiss the banner if present
Selenium 4 Medium
List<WebElement> accept = driver.findElements(By.id("onetrust-accept-btn-handler"));
if (!accept.isEmpty() && accept.get(0).isDisplayed()) {
accept.get(0).click();
new WebDriverWait(driver, Duration.ofSeconds(5))
.until(ExpectedConditions.invisibilityOf(accept.get(0)));
}
accept = driver.find_elements(By.ID, "onetrust-accept-btn-handler")
if accept and accept[0].is_displayed():
accept[0].click()
WebDriverWait(driver, 5).until(EC.invisibility_of_element(accept[0]))
const accept = await driver.findElements(By.id('onetrust-accept-btn-handler'));
if (accept.length && await accept[0].isDisplayed()) {
await accept[0].click();
await driver.wait(until.elementIsNotVisible(accept[0]), 5000);
}
var accept = driver.FindElements(By.Id("onetrust-accept-btn-handler"));
if (accept.Count > 0 && accept[0].Displayed)
{
accept[0].Click();
new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(d => !accept[0].Displayed);
}

A modal is opening or closing

After closing a modal, wait for the backdrop element (for Bootstrap, .modal-backdrop) to be removed or invisible before clicking anything underneath. After opening one, wait for the modal’s own button to be visible rather than clicking the instant it is in the DOM.

The driver scrolls the element into view, which can place it right under a fixed header. Scroll it to the centre of the viewport first, then click.

Centre the element before clicking
Selenium 4 Medium
WebElement link = driver.findElement(By.linkText("Pricing"));
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView({block: 'center'});", link);
link.click();
link = driver.find_element(By.LINK_TEXT, "Pricing")
driver.execute_script("arguments[0].scrollIntoView({block: 'center'});", link)
link.click()
const link = await driver.findElement(By.linkText('Pricing'));
await driver.executeScript("arguments[0].scrollIntoView({block: 'center'});", link);
await link.click();
IWebElement link = driver.FindElement(By.LinkText("Pricing"));
((IJavaScriptExecutor)driver).ExecuteScript(
"arguments[0].scrollIntoView({block: 'center'});", link);
link.Click();

The element is still animating

Wait for the animation to finish: either a class that marks the end state (for example .show or aria-expanded="true"), or for the element’s position to stop changing between two polls. A custom wait condition that compares getRect() across polls works well. Ask developers whether animations can be disabled in test builds with prefers-reduced-motion.

The layout differs at the current window size

Set an explicit window size, for example --window-size=1920,1080 for headless Chrome, so elements do not overlap in a cramped viewport. Run headed and headless at the same size.

Warning: Clicking via JavaScript (arguments[0].click()) makes the error go away because it skips the hit test. It also means your test passes when a real user could not click the button. Use it only when you have confirmed the overlay is irrelevant to users, as in the JavaScript click fallback recipe.

How to prevent it

  • Model loading states in your page objects: every action that triggers an XHR waits for its spinner to go.
  • Handle consent banners centrally (a cookie set in a fixture or a one-time dismiss) instead of in each test.
  • Pin the window size in your driver factory.
  • Disable animations in test environments where the product allows it.
  • On failure, capture a screenshot; the overlay is usually obvious in the image.

Go deeper