high

Error: browser has been closed

An operation was attempted on a browser or page that has already been closed. This often happens in afterEach hooks or when tests share browser instances incorrectly.

Common Causes

  1. 1Test cleanup closed the browser before other tests finished
  2. 2browser.close() called in afterAll while tests are still running
  3. 3Unhandled exception in one test caused browser to close, affecting subsequent tests
  4. 4Using a shared browser instance across test files

How to Fix

Use Playwright's built-in fixtures

// Use the built-in 'page' fixture — Playwright manages lifecycle
test('my test', async ({ page }) => {
  await page.goto('/');
  // page is automatically created and destroyed per test
});

Playwright's test fixtures handle browser lifecycle automatically. Avoid manual browser management.

How ObserveOne Helps

ObserveOne manages test environments and ensures clean browser lifecycle management across your test suite.

Start Monitoring Free

Related Errors