100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Testing

Tracing and Debugging with Playwright Inspector

How to use Playwright's Trace Viewer and Inspector to diagnose flaky and failing tests, both locally and in CI.

Advanced FeaturesIntermediate9 min readJul 10, 2026
Analogies

Tracing and Debugging with Playwright Inspector

When a test fails in CI, a stack trace and a single screenshot rarely explain why; you need to see the sequence of actions, the DOM at each step, and the network requests that were in flight. Playwright's tracing feature solves this by recording a self-contained trace.zip file per test that captures a full timeline: every action, DOM snapshots before and after each step, console logs, network activity, and (optionally) screenshots or video, which can then be replayed and inspected offline in the Trace Viewer.

🏏

Cricket analogy: It's like a stump-mic-and-multi-angle broadcast package handed to the third umpire instead of just the final scoreboard reading, letting them reconstruct exactly what happened ball by ball rather than guessing from the result.

Recording and Viewing Traces

Tracing is enabled per test run via context.tracing.start({ screenshots: true, snapshots: true, sources: true }) followed by context.tracing.stop({ path: 'trace.zip' }), though in practice most projects configure it declaratively in playwright.config.ts with the trace option set to 'on', 'off', 'retain-on-failure', or the more common 'on-first-retry'. Once a trace.zip exists, running npx playwright show-trace trace.zip opens a local web UI where you can scrub through a timeline of actions, click any step to see the exact DOM snapshot at that moment, inspect the Network tab for every request/response, and read console output — all without needing to re-run the test.

🏏

Cricket analogy: It's like scrubbing through a Hot Spot replay timeline ball by ball on the broadcast desk, clicking any delivery to see the exact bat-pad contact frame, instead of only watching the live feed once in real time.

Using the Playwright Inspector

While Trace Viewer is for post-mortem analysis after a run finishes, the Playwright Inspector is for live, interactive debugging: setting PWDEBUG=1 before running a test, or inserting an explicit await page.pause() call inside the test, opens a paused browser window alongside an Inspector panel with step-over controls, a locator picker that highlights matching elements when you hover generated selectors, and a live console for testing locator expressions against the actual page before committing them to code. This is the fastest way to figure out why a selector isn't matching or why a click isn't landing where you expect, since you can experiment directly against the real, running page state instead of guessing from a stack trace.

🏏

Cricket analogy: It's like a batting coach freezing a net session mid-delivery to physically walk out and adjust a batter's grip in real time, rather than only reviewing the footage afterward.

Debugging Failures in CI

Recording a full trace with screenshots and video for every single test run is expensive in both time and storage, so the recommended CI configuration is trace: 'on-first-retry' combined with screenshot: 'only-on-failure' and video: 'retain-on-failure' in playwright.config.ts — this way passing tests produce no artifacts at all, while a failing test that gets retried produces a complete trace.zip, a failure screenshot, and a video, uploaded as CI artifacts for later download. Downloading that trace.zip from a failed CI run and opening it locally with npx playwright show-trace almost always reveals the root cause immediately, since you can see the exact DOM state, network response, and console error at the moment the assertion failed, without needing to reproduce the flake on your own machine.

🏏

Cricket analogy: It's like a stadium only archiving full multi-angle broadcast footage for matches that go to a controversial finish, rather than storing every camera feed from every bilateral ODI ever played, to save storage while keeping what actually matters.

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

export default defineConfig({
  use: {
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
  },
  retries: process.env.CI ? 2 : 0,
});

// checkout.spec.ts
import { test, expect } from '@playwright/test';

test('checkout applies discount code', async ({ page }) => {
  await page.goto('/cart');
  await page.pause(); // opens Playwright Inspector for live debugging
  await page.getByPlaceholder('Promo code').fill('SAVE10');
  await page.getByRole('button', { name: 'Apply' }).click();
  await expect(page.getByText('10% discount applied')).toBeVisible();
});

Run npx playwright show-trace trace.zip (or drag the .zip into trace.playwright.dev) to open the Trace Viewer's Actions, Network, Console, and Source tabs for a completed run — no browser or test re-execution required, since the trace is a fully self-contained artifact.

Setting trace: 'on' for every run in CI (rather than 'on-first-retry' or 'retain-on-failure') will substantially slow down your suite and bloat artifact storage — reserve full always-on tracing for local debugging sessions, not routine CI runs.

  • Trace Viewer records a timeline of actions, DOM snapshots, network activity, and console logs into a self-contained trace.zip file.
  • npx playwright show-trace opens a recorded trace for post-mortem, offline inspection without re-running the test.
  • Playwright Inspector (PWDEBUG=1 or await page.pause()) enables live, interactive debugging against the actual running page.
  • The Inspector's locator picker and live console let you validate selectors against real DOM state before writing them into code.
  • trace: 'on-first-retry' in playwright.config.ts is the recommended CI setting, capturing a trace only when a test fails and retries.
  • Pairing trace: 'on-first-retry' with screenshot: 'only-on-failure' and video: 'retain-on-failure' keeps passing runs artifact-free.
  • Downloading a failed CI run's trace.zip usually pinpoints the root cause without needing to reproduce the flake locally.

Practice what you learned

Was this page helpful?

Topics covered

#Testing#PlaywrightStudyNotes#TestingQA#TracingAndDebuggingWithPlaywrightInspector#Tracing#Debugging#Playwright#Inspector#StudyNotes#SkillVeris

Frequently Asked Questions

21 categories · pick one to explore

Where can I get free study notes for programming and tech subjects?
SkillVeris offers completely free study notes covering programming and tech subjects, with no signup fees or paywalls. The notes are structured by course and topic, written for quick understanding, and enriched with the Learn Through Hobbies analogy method, so you can revise concepts through cricket, music, gaming, cooking and more.
Are SkillVeris study notes good for exam revision?
Yes, the study notes are designed for efficient revision: each topic answers its heading immediately, keeps explanations concise, and links to related glossary terms and cheat sheets. Students preparing for university exams or certification tests use them as quick revision notes because they distil concepts without the padding of full textbooks.
What subjects do the free study notes cover?
The study notes span the platform's main domains, including AI and machine learning, Python and programming, web development, DevOps, cloud, security and databases. Coverage mirrors the 37 live courses, so notes exist for the topics you are actually studying, and new note sets are added as courses launch.
How are SkillVeris study notes different from regular textbooks?
The notes are answer-first, concise and free, whereas textbooks are long and often expensive. Each section explains one concept directly, then reinforces it through selectable hobby analogies like cricket or cooking. Notes also cross-link to the glossary, blog and cheat sheets, letting you jump to related material instantly instead of flipping pages.
Can I use the developer study material without creating an account?
The study notes are free to access, and SkillVeris does not charge anything for its developer study material at any point. Browsing notes is straightforward from the Study Notes section, and if you want progress tracking, certificates and AI Mentor conversations tied to your learning, a free account unlocks those extras.
Do the study notes explain concepts with analogies?
Yes, this is a signature SkillVeris feature. Study notes use the Learn Through Hobbies method, explaining technical concepts through analogies from twelve domains including cricket, music, gaming, photography, travel, movies, fitness, chess, cooking, finance, business and sports. You can switch the analogy domain instantly to whichever hobby makes the concept click.
Are the revision notes suitable for last-minute exam preparation?
Yes, revision notes on SkillVeris work well for last-minute preparation because every section states the answer in its first sentences, so skimming is genuinely effective. Pair them with the relevant cheat sheet for formulas and syntax, and use the glossary for any unfamiliar term you meet while cramming.
Is there free study material for AI and machine learning?
Yes, SkillVeris provides free study notes across its AI and ML catalogue, covering Python for AI, deep learning frameworks like PyTorch and TensorFlow, Hugging Face Transformers, Large Language Models, RAG, AI agents and MLOps. All of it is free, making it a strong resource for Indian students and global learners alike.
Can beginners understand the study notes, or are they for experts?
Beginners can absolutely use them. The notes are written in plain language, define terms as they appear, and lean on hobby analogies to make abstract ideas concrete. Difficulty scales with the underlying course level, so beginner-course notes stay gentle while advanced-course notes go deeper, and the glossary supports you throughout.
How do study notes connect with SkillVeris courses?
Study notes are organised by course and topic, so they map directly to the structured courses and their 24–40-lesson curriculum. Many learners study a lesson first, then use the matching notes for revision before module assessments and the final exam, where 80 percent is required to pass and earn the certificate.
Are there study notes for Python specifically?
Yes, Python is well covered through notes tied to the Python-focused courses, including Python for AI and ML. Topics span fundamentals through applied machine learning usage. You can reinforce the notes with Python practice in Code Lab, which runs code in your browser with no installation required.
Do the study notes include code examples?
Yes, study notes include code examples wherever a concept is best shown in code, alongside explanations, key points and analogies. Reading a snippet in the notes and then reproducing it yourself in Code Lab is an effective loop, since Code Lab lets you run code in the browser across six languages.
How often is new study material added to SkillVeris?
Study material grows alongside the course catalogue. Whenever new courses join the platform's 37 live courses, matching study notes, glossary entries and cheat sheets are added so the resources stay in sync. Existing notes are also refined over time, so it is worth revisiting topics you studied earlier.
Can I use SkillVeris notes to prepare for technical interviews?
Yes, the notes make excellent interview revision because they compress each concept into direct, answer-first explanations, which mirrors how you should answer interview questions. Combine them with the SkillVeris interview questions feature, which includes readiness scoring, to test whether your revision has actually made you interview-ready.
Are the study notes mobile-friendly for studying on the go?
Yes, the study notes are built to load fast and read comfortably on mobile devices, so you can revise during a commute or between classes. Sections are short and answer-first, which suits small screens, and analogy switching works on mobile too, letting you study anywhere without carrying books.
What is the difference between study notes and cheat sheets?
Study notes explain concepts in depth with context, examples and analogies, making them ideal for learning and revision. Cheat sheets are compact quick-reference summaries of syntax, commands and key facts, ideal once you already understand a topic. Most learners study the notes first, then keep the cheat sheet handy while coding.
Do study notes help if I am stuck on a course lesson?
Yes, reading the matching study notes often clarifies a lesson because the same concept is explained from a different angle, frequently with a different analogy. If you are still stuck, ask the AI Mentor, which answers 24/7 at Quick, Detailed or Deep-dive depth until the idea genuinely makes sense.
Is there free study material for DevOps and cloud topics?
Yes, SkillVeris carries free study notes for DevOps and cloud topics as part of its coverage across 37 live courses. The material suits learners following the DevOps Engineer or Cloud Engineer paths, and it links to related glossary terms and cheat sheets so you can revise the whole toolchain in one place.
Can school or college students in India use these notes for projects?
Yes, students across India and worldwide use SkillVeris notes for coursework, projects and exam preparation, and everything is free, which matters for student budgets. The notes explain concepts clearly enough to cite in project reports, and Code Lab lets you prototype the project code directly in your browser.
How should I combine study notes with other SkillVeris resources?
A proven loop: learn from a course lesson, revise with the matching study notes, look up unfamiliar terms in the glossary, keep the cheat sheet open while practising in Code Lab, and quiz yourself with interview questions. The AI Mentor fills any remaining gaps 24/7, at whatever depth you need.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse