medium

Error: element is intercepted by another element

Another element (like a modal, overlay, or tooltip) is covering the target element, preventing Playwright from clicking it.

Common Causes

  1. 1Cookie consent banner covering the element
  2. 2Loading spinner or overlay blocking the page
  3. 3Sticky header/footer covering the element
  4. 4Tooltip or dropdown from another element overlapping
  5. 5z-index stacking issue

How to Fix

Close the intercepting element first

// Close cookie banner
const banner = page.locator('[data-testid="cookie-banner"]');
if (await banner.isVisible()) {
  await banner.locator('button').click();
}
await page.locator('#target').click();

Dismiss overlays, modals, or banners before interacting with the target element.

Scroll the element into clear view

await page.locator('#target').scrollIntoViewIfNeeded();
await page.locator('#target').click();

Ensures the element is scrolled into view and not behind a sticky header.

How ObserveOne Helps

ObserveOne detects overlay and z-index issues across your application and flags elements that may cause interaction failures.

Start Monitoring Free

Related Errors