medium

Error: element is not visible

The target element exists in the DOM but is not visible. Playwright requires elements to be visible before interacting with them (clicking, typing, etc.).

Common Causes

  1. 1Element has display: none or visibility: hidden
  2. 2Element is behind another element (z-index issue)
  3. 3Element is outside the viewport
  4. 4Element is in a collapsed dropdown, modal, or accordion
  5. 5CSS animation hasn't completed yet

How to Fix

Wait for the element to become visible

await page.locator('#element').waitFor({ state: 'visible' });
await page.locator('#element').click();

Explicitly wait for the visible state before interacting.

Force the click (use sparingly)

await page.locator('#element').click({ force: true });

Bypasses visibility checks. Only use when you're certain the element should be clicked despite not being visible (e.g., custom dropdowns).

How ObserveOne Helps

ObserveOne monitors element visibility states and alerts when elements that should be visible are unexpectedly hidden.

Start Monitoring Free

Related Errors