Home  Playwright   How trace v ...

How Trace Viewer works in playwright when some browsers do not support CDP

Playwright’s trace viewer works even in Safari (WebKit) and Firefox — even though those browsers don’t support CDP natively. Let’s break down how.


🧠 How Playwright Trace Viewer Works

Playwright’s trace viewer isn’t browser-dependent — it’s framework-level tracing, not low-level browser tracing. Here’s what actually happens:

1. Playwright Hooks into Its Own API Layer

Playwright internally wraps all browser automation calls (click, fill, goto, locator, etc.). When you enable tracing (context.tracing.start()), Playwright records:

So even for WebKit (Safari) or Firefox, Playwright doesn’t rely on CDP — it logs actions within its own automation layer.


2. Cross-Browser Architecture

Playwright has browser-specific drivers:

Each driver speaks to its browser through a native protocol:

When tracing is enabled, these drivers send telemetry back to the Playwright core. That’s why tracing works across all browsers — including Safari.


3. The Trace File

All this data is stored in a .zip file (usually trace.zip) that contains:

You can open this in:

npx playwright show-trace trace.zip

And view it in Playwright’s visual Trace Viewer UI, which replays actions like a time machine.


✅ Key Difference from CDP Traces

AspectCDP / ChromePlaywright Trace
SourceBrowser’s native debugging protocolPlaywright’s cross-browser automation layer
CoverageOnly Chromium-based browsersWorks across Chromium, Firefox, WebKit
DepthDeep browser internals (JS execution, memory, etc.)Test-level details (steps, DOM, screenshots, logs)
Use CaseBrowser devtools, profilingTest debugging and replay

So to summarize:

🧩 Playwright Trace Viewer doesn’t depend on CDP. It records at the framework level, so it can replay interactions even on browsers that don’t expose CDP — like Safari.


Published on: Oct 17, 2025, 12:56 AM  
 

Comments

Add your comment