Skip to content

Playwright Trace Viewer Not Opening Fix

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about Playwright Trace Viewer Not Opening Fix. We cover key concepts, practical examples, and best practices.

Your Playwright trace files aren't generated — or the trace viewer doesn't open when you try to view them.

The Problem

// WRONG — trace not configured
import { test } from '@playwright/test';

test('login flow', async ({ page }) => {
  // No trace recorded — nothing to debug with
});

No trace files exist, so you can't use the trace viewer to debug failures.

Step-by-Step Fix

1. Enable tracing in config

// RIGHT — playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: {
    trace: 'retain-on-failure',
  },
});

2. Choose trace mode

// RIGHT — trace modes
export default defineConfig({
  use: {
    // 'off' — no trace (default)
    // 'on' — trace all tests
    // 'retain-on-failure' — trace, keep only on failure
    // 'on-first-retry' — trace on first retry
    // 'on-all-retries' — trace on all retries
    trace: 'on',
  },
});

3. Enable trace per test

// RIGHT — per-test tracing
import { test } from '@playwright/test';

test.use({ trace: 'on' });

test('debug this test', async ({ page, trace }) => {
  await page.goto('https://example.com');
  // Full trace recorded for this test
});

4. View traces

# RIGHT — open trace viewer
npx playwright show-trace path/to/trace.zip

# Or open the HTML report
npx playwright show-report

5. Programmatic trace control

// RIGHT — manual trace start/stop
test('manual trace', async ({ page, context }) => {
  await context.tracing.start({ screenshots: true, snapshots: true });

  await page.goto('https://example.com');
  await page.click('button');

  await context.tracing.stop({ path: 'trace.zip' });
});

Expected output:

✓ login flow (1.2s) [trace attached]

View trace: npx playwright show-trace test-results/login-flow/trace.zip

Prevention Tips

  • Enable trace: 'retain-on-failure' in config
  • Use trace: 'on' for specific tests you're debugging
  • Open traces with npx <a href="/testing-qa/playwright/">playwright</a> show-trace
  • Use the trace viewer to inspect DOM snapshots and network logs
  • Set screenshots: true and snapshots: true for full detail

Common Mistakes with trace viewer

  1. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  2. Misunderstanding that String is [Char] with poor performance for large text operations
  3. Using foldl instead of foldl' causing stack overflow on large lists

These mistakes appear frequently in real-world PLAYWRIGHT code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What information does a Playwright trace contain?

Console logs, network requests (with bodies), DOM snapshots, screenshots at each action, source map locations, and test steps. Traces are saved as .zip files.

How do I view traces in CI?

Upload trace files as CI artifacts. Use npx <a href="/testing-qa/playwright/">playwright</a> show-trace to view them locally after downloading. The HTML report also embeds traces.

Are traces the same as videos?

No. Traces are rich diagnostic files with DOM snapshots, network logs, and console output. Videos are screen recordings. Use traces for debugging, videos for visual verification.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro