medium

Error: frame was detached

The iframe or frame that was being interacted with was removed from the DOM during the operation. This commonly occurs with dynamic content that swaps iframes.

Common Causes

  1. 1Page navigation caused the iframe to be removed
  2. 2JavaScript removed the iframe from the DOM
  3. 3SPA route change unmounted the iframe component
  4. 4Ad or embed iframe was dynamically replaced

How to Fix

Re-locate the frame after page changes

// Wait for the new frame to appear
await page.waitForSelector('iframe#embed');
const frame = page.frameLocator('iframe#embed');
await frame.locator('#button').click();

After page changes, the frame reference becomes stale. Re-locate it using frameLocator.

How ObserveOne Helps

ObserveOne tracks iframe lifecycle events and alerts when frames are unexpectedly detached during test execution.

Start Monitoring Free

Related Errors