Skip to main content

Debugging Tests

Playwright Inspector

Playwright Inspector is a GUI tool that helps authoring and debugging Playwright scripts. That's our default recommended tool for scripts troubleshooting.

Playwright Inspector

There are several ways of opening Playwright Inspector:


Set the PWDEBUG environment variable to run your scripts in debug mode. This configures Playwright for debugging and opens the inspector.

# Source directories in the list are separated by : on macos and linux and by ; on win.
PWDEBUG=1 PLAYWRIGHT_JAVA_SRC=<java source dirs> mvn test

Additional useful defaults are configured when PWDEBUG=1 is set:

  • Browsers launch in the headed mode
  • Default timeout is set to 0 (= no timeout)

Using PWDEBUG=console will configure the browser for debugging in Developer tools console:

  • Runs headed: Browsers always launch in headed mode
  • Disables timeout: Sets default timeout to 0 (= no timeout)
  • Console helper: Configures a playwright object in the browser to generate and highlight Playwright locators. This can be used to verify locators.
PWDEBUG=console mvn test


Call Page.pause() method from your script when running in headed browser.

// Pause on the following line.

Use open or codegen commands in the Playwright CLI:

mvn exec:java -e -D -D exec.args="codegen"

Stepping through the Playwright script

The Inspector opens up a browser window highlighting the elements as you step through each line of the test. Use the explore button to pick a locator which you can then copy into your test file and rerun your tests to see if they pass.

Paused on line

Use the toolbar to play the test or step over each action using the "Step over" action (keyboard shortcut: F10) or resume script without further pauses (F8):

Stepping toolbar

Now we know what action is about to be performed and we can look into the details on that action. For example, when stopped on an input action such as click, the exact point Playwright is about to click is highlighted with the large red dot on the inspected page:

Red dot on inspected page

Actionability Logs

By the time Playwright has paused on that click action, it has already performed actionability checks that can be found in the log:

Action log

If actionability can't be reached, it'll show action as pending:

Pending action

Exploring selectors

Use the Explore button to hover over an element on the page and explore it's selector by clicking on it. You can then copy this selector into your tests and rerun your tests to see if they now pass with this selector. You can also debug selectors, checkout our debugging selectors guide for more details.

Browser Developer Tools

You can use browser developer tools in Chromium, Firefox and WebKit while running a Playwright script in headed mode. Developer tools help to:

  • Inspect the DOM tree and find element selectors
  • See console logs during execution (or learn how to read logs via API)
  • Check network activity and other developer tools features
Chromium Developer Tools

Using a Page.pause() method is an easy way to pause the Playwright script execution and inspect the page in Developer tools. It will also open Playwright Inspector to help with debugging.


For WebKit: launching WebKit Inspector during the execution will prevent the Playwright script from executing any further.

Headed mode

Playwright runs browsers in headless mode by default. To change this behavior, use headless: false as a launch option. You can also use the slowMo option to slow down execution (by N milliseconds per operation) and follow along while debugging.

chromium.launch(new BrowserType.LaunchOptions() // or firefox, webkit