high

TimeoutError: waiting for selector

Playwright waited for an element matching the given selector but it did not appear within the timeout. The element may not exist, may be hidden, or may appear under a different selector.

Common Causes

  1. 1Selector typo or incorrect CSS/XPath expression
  2. 2Element is rendered dynamically and hasn't appeared yet
  3. 3Element exists but is hidden (display: none or visibility: hidden)
  4. 4Element is inside a shadow DOM or iframe
  5. 5Page content changed and the selector no longer matches

How to Fix

Use Playwright's auto-waiting locators

// Instead of:
await page.waitForSelector('#button');
await page.click('#button');

// Use:
await page.locator('#button').click();

Playwright locators automatically wait for elements. No need for explicit waitForSelector in most cases.

Debug with page.locator().count()

const count = await page.locator('#button').count();
console.log('Elements found:', count);

Check if the selector matches any elements at all. Helps distinguish between 'wrong selector' and 'element not loaded yet'.

Handle iframes explicitly

const frame = page.frameLocator('#my-iframe');
await frame.locator('#button').click();

If the element is inside an iframe, you need to use frameLocator to access it.

How ObserveOne Helps

ObserveOne's self-healing selectors automatically detect when selectors break and suggest fixes based on AI analysis.

Start Monitoring Free

Related Errors