low

Error: Failed to take screenshot

Playwright failed to capture a screenshot. This usually happens when the page or browser context is in an invalid state.

Common Causes

  1. 1Page has already been closed when screenshot is attempted
  2. 2Browser crashed before screenshot could be taken
  3. 3Disk space full — cannot write screenshot file
  4. 4Invalid file path for screenshot output

How to Fix

Guard screenshot calls

try {
  if (!page.isClosed()) {
    await page.screenshot({ path: 'screenshot.png' });
  }
} catch (e) {
  console.warn('Screenshot failed:', e);
}

Check if the page is still open before taking a screenshot, especially in error handlers.

How ObserveOne Helps

ObserveOne automatically captures visual states during test execution and stores them for debugging, even when screenshots fail.

Start Monitoring Free

Related Errors