Blog Details Shape
Automation testing
AI
CI/CD
Automation framework

How to Use Playwright Trace Viewer for Faster Debugging?

Published:
June 27, 2025
Table of Contents
Join 1,241 readers who are obsessed with testing.
Consult the author or an expert on this topic.

Three years ago, I discovered Playwright Trace Viewer while helping our team debug a complex audio processing application. What started as curiosity became a game-changer that now saves us hours every week.

We had this complex flow where users could upload audio files, apply effects, and export them. Screenshots were our go-to debugging tool, until they weren't.

One day, a test kept failing in CI. The screenshot showed everything looked perfect. The upload button was there, the file was selected, but the processing never started.

Hours of head-scratching later, I opened the trace file.

The timeline revealed what screenshots couldn't: the upload started, hung for 8 seconds (invisible in screenshots), then silently failed with a 413 error in the network tab. The audio file was too large for our nginx config.

Ten minutes to resolution instead of three hours of guesswork.

Playwright Trace Viewer: Your New Debugging Superpower

The moment I shared this with my team, everyone wanted in. We'd been debugging blind, and suddenly we had X-ray vision into our tests.

1. Cut debugging time from hours to minutes

Here's what changed for us: A flaky test that took 3 hours to diagnose now takes 10 minutes, not exaggerating. Last week, a junior dev fixed their first CI failure without asking for help, just downloaded the trace, found a timeout in an API call, and pushed the fix.

The numbers back this up. Teams using Trace Viewer report finding root causes drastically faster than traditional debugging. One QA lead mentioned their team cut debugging time by 80% after adopting traces.

2. Why Playwright's approach stands out

Traditional tools give you breadcrumbs. Selenium might throw "Element not found." Cypress shows a video. But Playwright? It gives you the whole crime scene.

You get DOM snapshots you can inspect like a paused browser. Network requests with full details. Console logs tied to exact moments. It's not just recording what happened; it's preserving the entire browser state at each step.

While Trace Viewer revolutionized our debugging, modern testing demands more. That's why we're building TestDino at Alphabin, unifying test observability, intelligent reporting, and AI-powered generation in one platform. Learn how we're solving testing's biggest challenges.

{{cta-image}}

Playwright Trace Viewer 101

Let me break down what actually happens when you enable tracing.

1. What's inside a trace file

A trace.zip contains everything: every click, every network call, every DOM change. It's like a black box recorder for your tests.

When I first opened one, I was surprised it included:

  • Screenshots before AND after each action
  • Full DOM snapshots (not just images, but HTML you can inspect)
  • Every console.log, warning, and error
  • Network waterfall with timings
  • The exact test code that ran

One trace from our audio app was 47MB. Heavy? Yes. Worth it? Absolutely.

2. Accessing traces: CLI, Web, and Remote

Three ways to open traces, depending on your workflow:

1. Local CLI: Perfect for debugging on your machine. Opens instantly.

npx playwright show-trace trace.zip
Copied!

2. Web viewer: Drag and drop your trace file. No installation needed. I use this when helping teammates, just share the .zip file.

trace.playwright.dev
Copied!

3. CI artifacts: Download from your pipeline GitHub Actions, Jenkins, wherever, grab the trace and debug locally.

3. Key components: Timeline, Actions, DOM, Network, Console

The interface splits into panels that tell your test's story:

  • The timeline shows every action as a bar. Long bar? That action was slow. Red marker? That's where it failed.
  • The actions panel lists what your test did, clicks, assertions, and navigations. Failed steps glow red. No more guessing where things went wrong.
  • DOM snapshots are the game-changer. Click any action, toggle between "Before" and "After" states. It's like having a time machine for your browser.
  • The network tab caught that 413 error in my audio app. Every request, response code, timing, it's all there.
  • Console logs show JavaScript errors that might not fail your test but explain weird behaviour. That "undefined is not a function"? Now you'll see it.

Getting Started with Playwright Trace Viewer

1. Configuring for different environments

Your playwright.config.ts needs one line:

use:{
 trace: 'on-first-retry'  // The golden standard
}
Copied!

Other options:

  • 'on' - Records everything (slows tests, huge files)
  • 'retain-on-failure' - Keeps only failed traces
  • 'off' - No tracing

2. CI/CD golden rule: trace: 'on-first-retry'

This setting is brilliant. First run: no tracing overhead. Test fails? Playwright automatically retries WITH tracing enabled.

You get traces only when needed. Your CI stays fast, storage stays manageable.

3. Smart file naming

By default, Playwright names traces sensibly: test-name-chromium-retry1.zip.

But you can get creative. We add build numbers:

name: `trace-${process.env.BUILD_ID}-${browserName}`
Copied!

Makes finding specific traces much easier when debugging historical failures.

Navigating the Playwright Trace Viewer Interface

This is where the magic happens. Let me show you how I use each feature.

1. Time-travel Debugging

Remember my audio processing bug? The trace showed something screenshots missed: between clicking "Process" and the error, there was a loading spinner that appeared for exactly 127ms.

Click any action, and see the page frozen at that moment. Not just a screenshot, the actual DOM. You can inspect elements, check computed styles, even see data attributes.

The "Before/After" toggle is brilliant. Click a button, toggle to "After", did the expected change happen? If not, why?

2. Timeline = instant clues

That first trace taught me to read the timeline like a story. Short bars = quick actions. Long bars = something's waiting.

In our audio app, I noticed uploads had wildly different bar lengths. Turns out, our test was uploading actual files of different sizes. The timeline made the pattern obvious.

Hover over any point, and preview screenshots appear. Scrub through like a video editor, finding the exact frame where things go wrong.

3. API sleuthing in network tab

Our audio processor made three API calls:

  1. Upload file
  2. Apply effects
  3. Generate preview

The network tab showed call #2 returning 500 errors, but only for files over 10 MB. Without traces, we'd have added random waits and hoped for the best.

Click any request for full details: headers, response, timing. It's like having Chrome DevTools for your failed CI run.

4. Tracking errors in console logs

Here's a fun one: Our test passed locally but failed in CI. The trace revealed why: a console error, "Audio Context was not allowed to start."

Chrome's autoplay policy was blocking our audio preview in headless mode. The test saw a timeout; the trace showed the real cause.

Advanced Debugging Techniques

After months of using Playwright Trace Viewer, I've developed some power moves.

1. Tackling flaky tests with trace comparison

Flaky test driving you crazy? Here's my approach:

  1. Run until it fails, save trace
  2. Run until it passes, save trace
  3. Open both side-by-side

I compare the action sequence, network timing, and console output. Usually, the difference jumps out, maybe an API responded 50ms slower, causing a race condition.

2. Multi-browser debugging tricks

WebKit trace showed our audio waveform renderer positioned 10px off. The Firefox trace? Perfect. Chrome trace? Also perfect.

Comparing traces across browsers immediately revealed CSS calc() differences. It would've taken hours of manual testing to find that.

3. Debugging authentication flows

Long setup killing your trace size? Use chunks:

await context.tracing.start({ screenshots: true, snapshots: true });
// ... login flow ...
await context.tracing.stopChunk({ path: 'login-trace.zip' });
await context.tracing.startChunk();
// ... actual test ...
await context.tracing.stopChunk({ path: 'test-trace.zip' });
Copied!

Now you have focused traces. Login fails? Check login-trace.zip. Testfails? Check test-trace.zip.

4. API mocks and network troubleshooting

We mock external APIs in tests. Playwright Trace Viewer shows whether mocks activated:

await page.route('**/api/process', route => {
  route.fulfill({ status: 200, body: mockResponse });
});
Copied!

Network tab confirms: "Fulfilled by route" instead of the actual network call. No more "did my mock work?" guessing.

5. Pinpointing performance bottlenecks

Test timing out? Check the timeline. We found our audio spectrum analyzer taking 12 seconds on CI (vs 2 seconds locally).

The trace showed why: CI machines had 1 CPU core, triggering a single-threaded fallback in our WebAssembly module.

CI/CD & Remote Debugging

1. GitHub Actions + trace artifacts

Our workflow:

- name: Run Playwright tests
  run: npx playwright test --trace on-first-retry
 
- name: Upload traces
  if: failure()
  uses: actions/upload-artifact@v3
  with:
	name: playwright-traces
	path: test-results/**/trace*.zip
	retention-days: 7
Copied!

Failed test? Download artifacts, open trace, fix issue. No more "works on my machine."

2. Viewing traces from CI failures

Pro tip: We added a bot that comments on PRs with failed tests:

"Test failed: audio-upload.spec.ts
Download trace | View in browser"

Developers can debug without even cloning the branch.

3. Sharing traces with your team

Trace files are self-contained. Slack them, attach to tickets, and drop in shared drives.

We keep a "Hall of Fame" folder of interesting failures. New team members review these to learn common pitfalls.

AI-Enhanced Debugging

This year, Playwright added AI features that feel like cheating (in a good way).

1. Using AI to speed up debugging

The "Copy Prompt" button was introduced in v1.50. One click generates a prompt with:

  • Error message
  • Test code snippet
  • Relevant trace context

Paste into ChatGPT, get a surprisingly good analysis. It once suggested: "The selector button.submit might be matching multiple elements. Try adding :visible or using more specific attributes."

It was right.

The convergence of AI and test automation is reshaping how we approach quality assurance.

2. Integrating GitHub Copilot and AI tools

VS Code integration is next level. Test fails, "Fix with AI" button appears. Click it, Copilot suggests:

await page.click('button.submit');
await page.click('button.submit:visible');
Copied!

Not always perfect, but it often points you in the right direction. Saved me countless hours on selector issues.

3. Visual action grouping and Git context

New test.step() grouping makes traces readable:

await test.step('Upload audio file', async () => {
  await page.click('#upload-button');
  await page.setInputFiles('input[type="file"]', 'audio.mp3');
  await page.click('#process-button');
});
Copied!

In traces, this appears as a collapsible "Upload audio file" section. Much cleaner than 20 individual actions.

These AI features are just the beginning. At Alphabin, we're taking it further with TestDino, imagine Trace Viewer's insights combined with automated test generation and intelligent failure analysis, all in one unified platform.

{{cta-image}}

Troubleshooting Common Issues

1.   Element not found

Trace shows the element wasn't in DOM? Check the Before snapshot; maybe the previous navigation failed.

Element exists, but test can't find it? Inspect the snapshot's HTML. I once spent an hour before realising our CSS changed id="submit" to id="submit-btn".

The locator helper (hover over the element in snapshot) is essential. Shows the exact selector Playwright would use.

2.  Timeout and race conditions

See a 30-second bar in the timeline? That's your timeout.

But why did it timeout? Check:

  • Network tab: API calls pending?
  • Console: JavaScript errors?
  • Snapshots: Element never appeared?

Our audio preview had a race: sometimes the waveform rendered before the play button initialised. Trace timeline showed the 50ms gap causing failures.

3.  Cross-browser issues

WebKit traces revealed our audio player used -webkit-appearance styles, Firefox ignored. Different browsers, different behaviours—traces make these visible.

4.  Async and dynamic content bugs

Modern apps are async nightmares. Traces help by showing exactly when things happen.

Our bug: Upload progress bar reached 100%, but success message took 2-8 seconds to appear (backend processing). Tests checking immediately after upload failed randomly.

Solution found via traces: Wait for specific network call completion, not UI updates.

Pro Tips & Best Practices

1. Code vs. config tracing

Config for failures, code for surgery:

// Config handles routine failures
trace: 'on-first-retry'
 
// Code for specific debugging
await context.tracing.start({
  screenshots: true,
  snapshots: true,
  sources: true  // Include source maps!
});
Copied!

2. Shrink trace size

Big traces? Try:

  • Split long tests
  • Use chunks for different sections
  • Disable screenshots for data-heavy operations

Our file upload tests generated 200MB traces. Now we disable tracing during actual upload, and re-enable it after.

3. Debug-friendly test design

Write tests that produce clear traces:

await test.step('Login as admin', async () => {
  // Login actions grouped together
});
 
await test.step('Upload large audio file', async () => {
  // Upload actions grouped
});
Copied!

Future you will thank present you.

4. Team workflows + IDE integration

VS Code + Playwright extension = debugging heaven. Test fails? Click trace link in test results. Opens immediately.

We pair-debug using traces. Senior dev shares screen, walks through trace: "See here? The API returned 401. Check your auth token."

Better than any documentation.

Conclusion: Next Steps

Quick-start checklist

  • Trace: 'on-first-retry' in playwright.config.ts
  • Configure CI to upload trace artifacts
  • Install VS Code Playwright extension
  • Run one test with-- trace on to practice
  • Try "Copy Prompt" on a real failure
  • Show your team a trace walkthrough

Pitfalls to avoid

  • Don't enable traces for all tests (kills performance)
  • Don't ignore traces when tests fail ("maybe it'll pass next time")
  • Don't share traces with sensitive data publicly
  • Don't trust AI fixes blindly
  • Don't forget to update Playwright regularly

Resources for continued learning

Start with Playwright's docs on debugging. Watch their YouTube demos.

The r/QualityAssurance subreddit has great Playwright discussions. Stack Overflow for specific issues.

Trace Viewer's role in your testing strategy

Playwright Trace Viewer tansformed how we approach testing. Failures aren't mysteries anymore; they're puzzles with all pieces visible.

For SaaS/FinTech teams running complex flows, traces are non-negotiable. They turn your test suite from a black box into a glass box.

Modern QA isn't about finding bugs; it's about understanding them quickly. Playwright Trace Viewer gives you that understanding.

Next time a test fails, don't rerun it hoping for green. Download the trace. Open it. The answer is usually right there, waiting for you to see it.

Something you should read...

Frequently Asked Questions

How do I use Playwright Trace Viewer?
FAQ ArrowFAQ Minus Arrow

Run your tests with tracing enabled to generate a trace.zip file, then open it using npx playwright show-trace trace.zip or upload it to trace.playwright.dev for analysis.

How can Trace Viewer improve debugging?
FAQ ArrowFAQ Minus Arrow

Trace Viewer lets you step through each test action, view DOM snapshots, network logs, and console output, making it easier to pinpoint where and why a test failed.

What are the key features of Trace Viewer?
FAQ ArrowFAQ Minus Arrow

It provides action timelines, screenshots, DOM and network snapshots, source code references, and detailed logs for every test step.

How do I analyze Trace Viewer results?
FAQ ArrowFAQ Minus Arrow

Click on actions to inspect state changes, review logs and network activity, and use snapshots to understand what happened before and after each step.

Discover vulnerabilities in your  app with AlphaScanner 🔒

Try it free!Blog CTA Top ShapeBlog CTA Top Shape
Discover vulnerabilities in your app with AlphaScanner 🔒

About the author

Pratik Patel

Pratik Patel

Pratik Patel is the founder and CEO of Alphabin, an AI-powered Software Testing company.

He has over 10 years of experience in building automation testing teams and leading complex projects, and has worked with startups and Fortune 500 companies to improve QA processes.

At Alphabin, Pratik leads a team that uses AI to revolutionize testing in various industries, including Healthcare, PropTech, E-commerce, Fintech, and Blockchain.

More about the author
Join 1,241 readers who are obsessed with testing.
Consult the author or an expert on this topic.
Pro Tip Image

Pro-tip

Related article:

Related article:

Related article:

Related article:

Related article:

Related article:

Related article:

Related article:

Related article:

Related article:

Related article:

Related article:

Related article:

Related article:

Related article:

Related article:

Related article:

Ready to cut debugging time by 80%. Look into TestDino.
Blog Newsletter Image

Don’t miss
our hottest news!

Get exclusive AI-driven testing strategies, automation insights, and QA news.
Thanks!
We'll notify you once development is complete. Stay tuned!
Oops!
Something went wrong while subscribing.