How to Fix Element Click Intercepted Error in Selenium
The
ElementClickInterceptedException in Selenium happens when another element blocks the one you want to click. To fix it, wait for the element to be clickable or scroll it into view before clicking using WebDriverWait and ExpectedConditions.element_to_be_clickable.Why This Happens
This error occurs because Selenium tries to click an element that is covered or blocked by another element, like a popup, loading spinner, or sticky header. The browser prevents the click on the intended element because something else is on top of it.
python
from selenium import webdriver from selenium.webdriver.common.by import By # Setup driver driver = webdriver.Chrome() driver.get('https://example.com') # This will cause ElementClickInterceptedException if element is blocked button = driver.find_element(By.ID, 'submit-button') button.click()
Output
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (x, y). Other element would receive the click: <div class="popup">...</div>
The Fix
Use WebDriverWait to wait until the element is clickable. This ensures no other element blocks it. Also, scroll the element into view if needed. This approach waits for the right moment to click safely.
python
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC # Setup driver driver = webdriver.Chrome() driver.get('https://example.com') # Wait until the button is clickable wait = WebDriverWait(driver, 10) button = wait.until(EC.element_to_be_clickable((By.ID, 'submit-button'))) # Scroll into view (optional but helpful) driver.execute_script('arguments[0].scrollIntoView(true);', button) # Now click safely button.click()
Output
No error; button clicked successfully
Prevention
- Always wait for elements to be clickable before clicking using
WebDriverWaitandExpectedConditions. - Check for popups, overlays, or loading spinners that might block clicks and wait for them to disappear.
- Scroll elements into view before clicking to avoid hidden or partially visible elements.
- Use explicit waits instead of fixed sleeps for more reliable tests.
Related Errors
Other similar Selenium errors include:
- ElementNotInteractableException: The element is present but not interactable (e.g., hidden or disabled).
- NoSuchElementException: The element is not found in the page DOM.
- StaleElementReferenceException: The element is no longer attached to the DOM after page updates.
Fixes usually involve waiting for the right conditions or re-finding elements.
Key Takeaways
Use explicit waits like WebDriverWait with element_to_be_clickable to avoid click interception.
Scroll elements into view before clicking to ensure visibility.
Wait for popups or overlays to disappear before interacting with elements.
Avoid fixed sleeps; rely on conditions for more stable tests.
Understand related Selenium exceptions to debug interaction issues effectively.