ElementClickInterceptedException
ElementClickInterceptedException: Causes and Fixes
Fix Selenium ElementClickInterceptedException (ElementClickInterceptedError in JS): overlays, cookie banners, sticky headers and animations blocking your click.
| 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
// Javaorg.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)# Pythonselenium.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
- A loading overlay or spinner is still covering the page after navigation or an XHR.
- A cookie consent banner, newsletter popup or chat widget sits over the content.
- A modal is opening or closing and its backdrop is still in the DOM during the CSS transition.
- A sticky header or footer covers the element after the driver scrolls it to the edge of the viewport.
- The element is still animating into position (slide-in menus, accordions), so the centre point lands on something else.
- 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.
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.
A cookie banner, popup or chat widget
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.
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.
A sticky header or footer
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.
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.
Related errors
- ElementNotInteractableException: the element itself is hidden or has no size, rather than covered.
- MoveTargetOutOfBoundsException: an Actions move landed outside the viewport.
- StaleElementReferenceException: the overlay caused a re-render and your element was replaced.
- TimeoutException: the overlay never disappeared within your wait.
Go deeper
- Click and Type Learn the fundamental Selenium interactions: clicking elements and typing text into input fields.
- Scrolling Scroll elements into view, scroll by an amount, use the W3C wheel actions, handle infinite scroll and sticky headers, and know when Selenium scrolls for you.
- Expected Conditions Use built-in expected conditions for common wait scenarios like visibility, clickability, and text presence.
- Common Errors Diagnose and fix the most common Selenium errors and exceptions.