Playwright Inspector: 4 Ways to Open It and Debug a Failing Test
Stuck on a Playwright test that times out? Open Playwright Inspector four ways, read its log, and fix the locator.
Playwright Inspector is a small window that pauses a running test so you can move through it one action at a time. You usually meet it when a spec that passed yesterday is red today.
The error says a click timed out, and that's all it says. So you rerun the job, add a wait, and lose an hour guessing.
This guide shows 4 ways to open the Inspector, how to read its log on one failing checkout test, and what to do when it won't open at all.
What Playwright Inspector is and when to reach for it
Playwright Inspector is a GUI debugger that ships with Playwright. It opens next to a real browser window and lets you step through a test, pick and edit locators, and read the checks Playwright ran before each action.
Reach for it when a test fails on your machine and the error text alone doesn't tell you why.
It's one tool inside the wider job of Playwright debugging. It's the one you use while the test is still running.
Note: Examples below use Playwright 1.65. Commands and Inspector behavior follow the official docs for that version.
What you see in the Inspector window
The window has four parts, and you'll use them in this order:
- Toolbar. Resume, pause, and step over, one action at a time.
- Source. Your spec file, with the action that's about to run highlighted.
- Locator field. It sits next to the Pick Locator button and shows the locator the test is paused on.
- Log. The checks Playwright made before the action, and the one it's still waiting on.

The browser window does its share too. Whatever the paused action targets gets highlighted on the page.
Inspector, UI mode, Trace Viewer, or the VS Code debugger
Playwright has several debugging tools, and four of them overlap enough to confuse people. Here's what each one is for, taken from the docs for each tool.
| Tool | How you open it | What it does | When it fits |
|---|---|---|---|
| Inspector | npx playwright test --debug | Steps through actions, picks and live edits locators, shows actionability logs | One failing test, live, in a headed browser |
| UI mode | npx playwright test --ui | Runs and watches tests with a time travel view and a watch mode | Writing and rerunning tests all day |
| Trace Viewer | npx playwright show-trace trace.zip | Replays a recorded trace: actions, DOM snapshots, console, network | After the run, including CI failures |
| VS Code debugger | Playwright extension, then Debug Test | Breakpoints, stepping, and error messages inside the editor | You already work in VS Code |
So the Inspector is for "this test is failing right now and I want to watch it". UI mode is for the loop of writing tests. The Playwright Trace Viewer is for a run that already ended.
One recommendation, and who should skip the Inspector. If you work in VS Code with the Playwright extension, you don't need it for daily work. The docs themselves recommend the extension, and it has the same Pick locator button without a second window.
The Inspector earns its place everywhere else: a terminal, another editor, or a Python, Java, or .NET project.
4 ways to open Playwright Inspector
You can open it with the --debug flag, the PWDEBUG=1 environment variable, a page.pause() call in a headed run, or the codegen command. The first three debug a test you already have. The fourth records a new one.

The --debug flag and the four settings it changes
This is the one you'll type most.
npx playwright test --debug
The debugging page mentions two changes: a headed browser and no timeout. The command line reference lists the full set. --debug is a shortcut for PWDEBUG=1 plus --timeout=0 --max-failures=1 --headed --workers=1.
Here's what each one means for your session:
- --headed opens a real browser window. The Inspector can't work without one, which is the practical side of the headless and headed split.
- --timeout=0 removes the test timeout, so nothing fails while you're reading. It's the one time you want Playwright timeouts switched off.
- --workers=1 runs one test at a time.
- --max-failures=1 stops the run at the first failed test.
Don't run it on the whole suite. The docs say it opens the Inspector and a browser window for each test, one by one. Point it at the test and the browser you care about.
npx playwright test tests/checkout.spec.ts:5 --project=chromium --debug
The :5 is the line where the test starts. Leave out --project and the same test runs once in every browser in your config.
Tip: Don't know the line number? Pick the test by title: npx playwright test -g "places an order" --project=chromium --debug.
PWDEBUG=1 on macOS, Linux, and Windows
PWDEBUG=1 is the same switch as an environment variable. It's also the way in for Python, Java, and .NET, where the test command has no --debug flag.
PWDEBUG=1 npx playwright test tests/checkout.spec.ts
$env:PWDEBUG=1
npx playwright test tests/checkout.spec.ts
set PWDEBUG=1
npx playwright test tests/checkout.spec.ts
Two things here trip people up.
First, PowerShell keeps the variable for the whole session. Microsoft's docs say a change "affects only the current session", and it stays until that session ends.
So every later run opens the Inspector until you remove it.
Remove-Item Env:PWDEBUG
Second, the value matters. Tutorials disagree here, so treat these values as the practical rule of thumb for current Playwright releases.
PWDEBUG=console gives you the playwright object in the DevTools console. PWDEBUG=0 and PWDEBUG=false turn debug mode off. Anything else opens the Inspector.
page.pause() at the line you care about
Stepping through twenty good actions to reach the bad one gets old fast. Put a pause right before the suspect line instead.
await page.getByLabel('Coupon code').fill('SAVE20');
await page.pause();
await page.getByRole('button', { name: 'Apply coupon' }).click();
Run the test with --debug and press Resume. The test runs and only stops on the page.pause() line.
You can also run it with plain --headed. The API reference says the method needs a headed browser, and it waits until you press Resume or call playwright.resume() in the DevTools console.
Codegen, when you want to record instead of debug
The fourth door opens the same window in a different mood.
npx playwright codegen http://localhost:4173/checkout
Two windows open: a browser where you click around, and the Inspector, which writes the test as you go. Stop the recording and the Pick Locator button appears, per the test generator docs.
It's a quick start for a new spec. Treat Playwright codegen output as a first draft you still need to review.
How to step through a failing test and read the actionability log
Open Playwright Inspector on the one failing test with --debug, step until it stops on the action that hangs, then read the log. The log names the check that's still waiting. That check is your cause, and you haven't changed a line yet.
Actionability log: the list of checks Playwright ran on an element before an action, such as visible, enabled, and stable, plus the check it is still waiting on.
The worked example: a checkout click that times out
Here is a simple checkout example. The spec below passed until a cookie banner shipped on that page.
import { test, expect } from '@playwright/test';
// Written before the cookie banner shipped.
test('places an order', async ({ page }) => {
await page.goto('/checkout');
await page.getByLabel('Coupon code').fill('SAVE20');
await page.getByRole('button', { name: 'Apply coupon' }).click();
await expect(page.getByTestId('order-total')).toHaveText('$80.00');
await page.getByRole('button', { name: 'Place order' }).click();
await expect(page.getByRole('status')).toHaveText('Order placed');
});
The test starts on line 5 and the first click is on line 8. Here's what the run printed, trimmed to the part that matters.
1) [chromium] › tests\checkout.spec.ts:5:1 › places an order
Test timeout of 30000ms exceeded.
Error: locator.click: Test timeout of 30000ms exceeded.
Call log:
- waiting for getByRole('button', { name: 'Apply coupon' })
- locator resolved to <button id="apply" type="button" class="btn-primary">Apply coupon</button>
- attempting click action
2 × waiting for element to be visible, enabled and stable
- element is visible, enabled and stable
- scrolling into view if needed
- done scrolling
- <div id="cookie-banner" class="cookie-banner">…</div> intercepts pointer events
- retrying click action
The answer is in there. It's also buried in a CI log, between a stack trace and a hundred other lines. In a normal run Playwright can retry that click dozens of times before the 30 seconds run out.
And notice something odd. The fill on the line above worked. Hold that thought.
Resume, step over, and the highlighted line
Now open the same test in the Inspector.
npx playwright test tests/checkout.spec.ts:5 --project=chromium --debug
The browser and the Inspector open together, and the test waits for you. Then:
- Press Step over. page.goto runs and the checkout page loads, banner and all.
- Press Step over again. The coupon field fills with SAVE20.
- Press Step over a third time. The click on Apply coupon starts, and it doesn't finish.

Here's the part that surprises people. In CI that click fails after 30 seconds. Under --debug the timeout is 0, so it never fails. The docs say the Inspector shows the action as pending when actionability can't be reached.
So don't wait for an error. Read the log.
The checks Playwright runs before a click
Before a click, Playwright waits for a set of checks to pass. The auto-waiting docs list them:
- The locator resolves to exactly one element.
- The element is visible: it has a non-empty bounding box and no visibility:hidden. An element with opacity:0 still counts as visible.
- The element is stable: the same bounding box for at least two animation frames in a row.
- The element is enabled.
- The element receives events: it's the hit target at the click point, with nothing sitting on top.
- The element is not inert: it isn't inside a subtree with the inert attribute.
Match that list to the log and the story is plain. "element is visible, enabled and stable" means the first checks passed. The cookie-banner line that "intercepts pointer events" is the receives-events check failing.

Now back to that fill. The same docs table shows fill checks visible, enabled, editable, and not inert. It doesn't check whether the element receives events. So the banner never stopped the typing. It stopped the first click.
Count the "Yes" cells in that table and the gap is easy to see.

In that table, click sits at the top with five checks, and press runs none.
The fix is what a user would do: close the banner first
test('places an order', async ({ page }) => {
await page.goto('/checkout');
await page.getByRole('button', { name: 'Accept all' }).click();
await page.getByLabel('Coupon code').fill('SAVE20');
await page.getByRole('button', { name: 'Apply coupon' }).click();
await expect(page.getByTestId('order-total')).toHaveText('$80.00');
await page.getByRole('button', { name: 'Place order' }).click();
await expect(page.getByRole('status')).toHaveText('Order placed');
});
That version passed on the first run.
The tempting shortcut is click({ force: true }). Don't. The docs say force disables non-essential checks, and the one it drops here is the check that just told you the truth. A real user can't click through that banner either.
The expect lines retry the same way actions do, so the reading skill carries over to assertions and to other Playwright test failures.
When one locator matches two elements
The second failure doesn't wait at all. Someone wrote the click with a CSS class.
await page.locator('.btn-primary').click();
Two buttons on the page share that class. This is what I got back.
Error: locator.click: Error: strict mode violation: locator('.btn-primary') resolved to 2 elements:
1) <button id="apply" type="button" class="btn-primary">Apply coupon</button> aka getByRole('button', { name: 'Apply coupon' })
2) <button id="place" type="button" class="btn-primary">Place order</button> aka getByRole('button', { name: 'Place order' })
Playwright locators are strict. An action throws if more than one element matches, and it throws at once. This test failed in under a second.
Tip: Read the aka part of a strict mode error first. It hands you a better locator for each match, and often that's the whole fix.
When the error isn't that generous, the Inspector is. That's next.
How to fix a locator with Pick Locator and live editing
Click Pick Locator, click the element in the browser, and the Inspector writes a locator into its field. Edit it there and watch which elements light up. Copy it into the spec when exactly one does.
Pick a locator from the page
With the test paused, press Pick Locator and hover over the page. The locator for whatever is under your pointer shows as you move. Click, and it lands in the field.
The docs describe how it chooses. It prioritizes role, text, and test id locators. If the first try matches several elements, it improves the locator until it points at one.
That's why a picked locator tends to read like getByRole('button', { name: 'Place order' }) and not like a CSS path. Role and name come from the accessibility tree, so the locator describes what a user sees, not how the page is styled.
If you want the reasoning behind each locator type, that's a longer topic: Playwright locators.
Edit the locator live and watch the matches
The field isn't read-only. Type in it, and matching elements highlight in the browser as you go.
Try it with the bad locator from earlier. Type locator('.btn-primary') and both buttons light up. That's the strict mode violation, visible before you run anything.

Here's the method I'd pass to a teammate. Call it the one-highlight check:
- Pause where the action happens, not earlier. A locator can match one element before a dialog opens and two after.
- Paste the locator into the field.
- Count the highlights. Zero means it's wrong. Two or more means strict mode will throw.
- Copy it into the spec only when one element lights up.
It's quick. And it replaces the "push and see what CI says" loop.
One more thing from the locator docs: CSS and XPath aren't recommended, because the DOM changes often. If the picker offers a role locator, take it.
Check a locator an AI agent wrote before you trust it
Maybe the spec in front of you started as agent output. Copilot, Cursor, or one of the Playwright test agents wrote the test, and it looks right.
Looking right isn't the same as matching one element at runtime. An agent that read the page through Playwright MCP saw a snapshot. An agent that didn't read the page guessed.
So run the one-highlight check on agent locators too. Add a page.pause() before the first action the agent wrote, open the test with --debug, and paste each locator into the field.
Zero highlights means the agent invented a name. You'll find that here, or in a red CI job later.
What to do when Playwright Inspector won't open
Check whether the browser is headless first. The Inspector needs a headed browser on a machine with a display, and without both there's no window to show. The table covers the cases with a documented cause.
| What you see | Cause | Fix |
|---|---|---|
| The test runs straight past page.pause() | The browser is headless, and pause needs headed mode | Add --headed or --debug |
| Headed run fails on a Linux CI agent | Headed execution on Linux needs Xvfb | Use a trace for CI failures |
| PWDEBUG=1 is set, but the browser runs on another machine | Playwright doesn't pass PWDEBUG to a remote machine | Set it where the browser launches, or use page.pause() |
| Windows: the test pauses and no window appears | Reported around 1.52 to 1.54, linked to Administrator terminals | Use a normal terminal and update Playwright |
| A window with a test list opens | You ran --ui, which is UI mode | Run --debug |
| The Inspector opens on every run | $env:PWDEBUG is still set in this PowerShell session | Remove-Item Env:PWDEBUG |
Headless runs, CI, and remote browsers
A headless run skips the pause. A quick check that logs the time around page.pause() shows how fast that return is.
page.pause() returned after 1 ms
ok 2 [chromium] › tests\pause.spec.ts:5:1 › forgotten pause (95ms)
One millisecond. No window, no wait, a passing test.
Remote browsers are the second case. In a GitHub thread, a Playwright maintainer wrote that Playwright "doesn't propagate PWDEBUG to the remote machine".
Set the variable where the browser launches, or use page.pause(). The same thread calls that the recommended way to open the Inspector in the middle of a test.
CI is the third case. The CI docs say headed execution on Linux agents needs Xvfb, a virtual display. You can add xvfb-run to a job in GitHub Actions, and the browser will launch.
But nobody is there to press Resume. So the Inspector is the wrong tool for a CI failure, even when you can force it open. What you need there is the evidence the run left behind.
Windows, admin terminals, and older versions
If the test pauses on Windows and no Inspector window shows up, check your version before anything else.
npx playwright --version
People reported exactly this after updating from 1.51 to 1.54. The maintainer's first suggestion was to try a normal terminal, not an Administrator one. The issue was closed as fixed in 1.55, and a user in the thread confirmed it.
So the fix has two parts. Open a normal terminal, and update.
npm install -D @playwright/test@latest
npx playwright install
A page.pause() you forgot to remove
You hit this the week after a debugging session. The pause is still in the spec, and it's on main.
In a headless CI job it does nothing. You saw the 1 ms result above. The danger is a headed job.
There, the pause waits for a Resume that never comes. And the test timeout won't save you. While a page is paused, the test runner switches timeouts off, so the usual test timeout will not end the wait.
Note: A headless run skips page.pause(). A headed run stops at it and waits, with the test timeout switched off.
The cheap guard is a lint rule. eslint-plugin-playwright ships no-page-pause (rule docs), and it's part of the plugin's recommended set.
import playwright from 'eslint-plugin-playwright';
export default [
{
...playwright.configs['flat/recommended'],
files: ['tests/**/*.ts'],
rules: {
...playwright.configs['flat/recommended'].rules,
'playwright/no-page-pause': 'error',
},
},
];
With ESLint and the Playwright plugin enabled, a committed pause looks like this.
tests\pause.spec.ts
8:9 error Unexpected use of page.pause() playwright/no-page-pause
If your specs use TypeScript-only syntax, ESLint also needs the typescript-eslint parser in that config. A committed pause is one of the easier Playwright mistakes to prevent.
Where the Inspector stops and CI debugging starts
The Inspector needs a headed browser and a person. A CI runner has neither. So for failures you didn't watch, record a trace and open it after the run, and keep the Inspector for the local repro.

Record a trace for the failures you didn't watch
A trace is a recording of the run that you can replay later. The trace docs recommend capturing one on the first retry in CI.
import { defineConfig } from '@playwright/test';
export default defineConfig({
retries: 1,
use: {
trace: 'on-first-retry',
},
});
That setting needs retries turned on. If you run without them, use trace: 'retain-on-failure'.
Then open the file from the CI artifacts.
npx playwright show-trace path/to/trace.zip
The good news: you already know how to read it. The trace has a Log tab with the same kind of lines you saw in the Inspector, "waiting for element to be visible, enabled and stable" included.
The slow part is the fetching. Find the job, download the zip, unzip, run the command. If your runs report to TestDino, the trace opens in the browser from the failed test, with its screenshots and video beside it.
Use --debug=cli when an agent does the debugging
A coding agent can't press Resume in a window. Playwright 1.59 added a second debug mode for that, listed in the release notes.
PLAYWRIGHT_HTML_OPEN=never npx playwright test tests/checkout.spec.ts --debug=cli
The test pauses at the start and prints a session name. The agent attaches with the Playwright CLI and drives the same pause, step, and resume controls as commands.
playwright-cli attach tw-a3f19c
playwright-cli pause-at tests/checkout.spec.ts:8
playwright-cli snapshot
playwright-cli resume
Your session name will differ. The full command list is in the test debugging docs.
Who should skip this? Anyone whose tests aren't touched by an agent. For a person, the Inspector window is easier.
If an agent is doing the fixing, it also needs to know what failed in CI. TestDino exposes that run history over MCP, so the agent can ask from the editor.
Tell a flaky failure from a real one
The cookie banner failed every single run. That's a real failure, and the log named it.
Some failures won't repeat for you. The test fails in CI, you open it with --debug, and it passes. Step through it five times and it passes five times.
Playwright has a name for half of this. With retries on, a test that fails and then passes on retry is reported as "flaky".
The other half is harder. A test that passes today and fails tomorrow looks fine in any single run, so you need history to see it.
That's the point where flaky tests stop being an Inspector problem. TestDino flags both kinds, fail-then-pass on retry and unstable across runs, and sorts each into a cause: timing, environment, network, assertion, or other.
Use the split this way. If it fails every time, open the Inspector. If it fails sometimes, look at the history first.
Conclusion
Playwright Inspector answers one question well: why is this action stuck right now?
Open the failing test with --debug, step to the action that hangs, and read the log before you touch the code. When the failure only shows up in CI, keep a trace ready and leave the Inspector for the local repro.
Often the log already names the cause. An overlay, a disabled button, a locator that matches two elements. Fix that, and skip the extra wait you were about to add.
Then cover the runs you can't watch. Turn on trace: 'on-first-retry', and add the no-page-pause rule so your debugging doesn't follow you into main.
Here's your next step. Take the last test that failed on your branch and open Playwright Inspector with --debug --project=chromium. If the log shows a check you don't recognize, the auto-waiting page defines every one.
FAQs

Krupa Gandhi
QA Tester