Skip to main content

Overview

The Playwright Inspector is a GUI tool that allows you to step through Playwright API calls, see debug logs, explore locators, and visually inspect the DOM during test execution. It’s essential for debugging failing tests and understanding test behavior.

Launching the Inspector

Debug Mode

The easiest way to use the Inspector is with the --debug flag:
This automatically:
  • Opens the Playwright Inspector
  • Runs tests in headed mode
  • Sets workers to 1
  • Disables timeout
  • Stops at the first failure

Debug Specific Tests

Environment Variable

You can also enable debug mode using the PWDEBUG environment variable:
This is useful in CI/CD pipelines or when you need more control over test execution options.

Inspector Interface

The Inspector window provides several key areas:

Action Log

Shows all Playwright API calls with:
  • Method name (e.g., page.goto(), page.click())
  • Arguments passed
  • Execution time
  • Success/failure status

Source Code View

Displays your test code with:
  • Current execution line highlighted
  • Ability to click line numbers to set breakpoints
  • Stack trace navigation

Toolbar Controls

1

Resume (F8)

Continue test execution until the next breakpoint or test end
2

Step Over (F10)

Execute the current line and pause at the next line in the same function
3

Step Into (F11)

Step into function calls to debug helper functions
4

Step Out (Shift+F11)

Continue until the current function returns

Using Breakpoints

Programmatic Breakpoints

Add breakpoints directly in your test code:

Conditional Breakpoints

Locator Exploration

The Inspector includes a powerful locator panel:

Pick Locator

  1. Click the “Pick Locator” button (or press Ctrl/Cmd+Shift+C)
  2. Hover over elements in the browser
  3. Click an element to copy its locator
The Inspector generates the best possible locator using:
  • Role-based selectors (preferred)
  • Text content
  • Test IDs
  • CSS selectors (fallback)

Test Locators

Type a locator in the input field to:
  • See matching elements highlighted in the browser
  • Verify selector specificity
  • Test different locator strategies

Inspector Features

Screencasting

The Inspector provides live screencasting through the Inspector API:
This is implemented in /home/daytona/workspace/source/packages/playwright-core/src/client/inspector.ts:31.

Console Logs

View console messages from the browser:
  • console.log()
  • console.error()
  • console.warn()
  • Uncaught exceptions

Network Activity

Inspect network requests:
  • Request URL and method
  • Response status
  • Request/response headers
  • Timing information

Debugging Best Practices

Start Small

Debug one test at a time with specific selectors using -g flag.

Use page.pause()

Add strategic pauses before actions that fail to inspect state.

Check Selectors

Use the locator panel to verify selectors match the expected elements.

Review Logs

Check console output for JavaScript errors or warnings.

Common Debugging Scenarios

Element Not Found

Timing Issues

Failed Assertions

Keyboard Shortcuts

Inspector vs Other Tools

The Inspector is different from browser DevTools. While DevTools shows the DOM and browser state, the Inspector shows Playwright API calls and test execution flow.
Use together:
  • Inspector: For Playwright-specific debugging (locators, API calls, test flow)
  • DevTools: For browser-specific debugging (DOM, CSS, JavaScript)
  • Trace Viewer: For post-execution analysis of completed tests

See Also