Skip to main content

Overview

Playwright UI Mode is an interactive test runner that combines the power of watch mode, the Inspector, and the Trace Viewer into a single experience. It’s designed for test development and debugging with live updates as you edit your code.

Starting UI Mode

Basic Command

This launches the UI Mode interface in a desktop application window (using Playwright’s own browsers).

Open in Browser Tab

Instead of a desktop window, open UI Mode in your default browser:
Specifying a host or port opens the UI in a browser tab, making it easier to share with team members or use on remote machines.

Port Configuration

UI Mode Interface

The UI Mode window is divided into several panels:

Test Explorer

Left sidebar showing:
  • All test files in your project
  • Test hierarchy (describe blocks, test cases)
  • Test status indicators:
    • ✅ Passed
    • ❌ Failed
    • ⏭️ Skipped
    • 🔄 Running
Click any test to:
  • Run it individually
  • View its trace
  • See test code

Filter Bar

Top section with controls:

Project Filter

Select which projects to run (Chromium, Firefox, WebKit)

Status Filter

Show only passed, failed, or skipped tests

Text Search

Filter tests by name or file path

Tags

Filter by test tags: @smoke, @slow, etc.

Action Timeline

When a test is selected, see:
  • Every action executed
  • Screenshots before/after each action
  • Network requests
  • Console logs
  • Execution timing

Watch Mode

UI Mode automatically watches for file changes. When you save a test file, it re-runs affected tests.

Running Tests

Run All Tests

Click the “Run All” button or press Ctrl+Shift+R (Windows/Linux) or Cmd+Shift+R (Mac).

Run Single Test

example.spec.ts
Click the play button next to the test name to run only that test.

Run Test File

Click the play button next to a file name to run all tests in that file.

Run by Project

Run tests only in specific browsers:
  1. Use project filter dropdown
  2. Select Chromium, Firefox, or WebKit
  3. Run tests

Time Travel Debugging

One of UI Mode’s most powerful features:

How It Works

  1. Run a test in UI Mode
  2. Click any action in the timeline
  3. See the exact state of the page at that moment
  4. Hover over elements to inspect them
  5. Copy locators from the DOM

Debugging Failed Tests

In UI Mode:
  1. Test fails and stops at the assertion
  2. Click on the failed action
  3. See the screenshot showing what was actually displayed
  4. Check the Console tab for errors
  5. Inspect the Network tab for failed requests
  6. Copy the correct locator

Live Trace View

UI Mode records traces automatically:
1

Run Test

Execute any test in UI Mode
2

Click Action

Click any action in the timeline
3

Explore State

View DOM snapshots, screenshots, network, and console
4

Pick Locators

Use Pick Locator tool to generate selectors
Unlike the Trace Viewer which analyzes saved traces, UI Mode provides live trace viewing as tests run.

Pick Locator Tool

Build selectors interactively:
  1. Click “Pick Locator” button
  2. Hover over elements in the page snapshot
  3. Click an element
  4. UI Mode generates the best locator:
  5. Copy and paste into your test

Watch Mode

UI Mode watches for changes:

What Triggers Re-runs

  • Saving test files (.spec.ts, .spec.js)
  • Saving helper files imported by tests
  • Changes to page objects or fixtures

What Doesn’t Trigger Re-runs

  • Config file changes (restart UI Mode)
  • Installing new dependencies
  • Changes to unrelated files

Customizing Watch Behavior

playwright.config.ts

Keyboard Shortcuts

UI Mode Features

Multiple Projects

Run tests across browsers:
playwright.config.ts
In UI Mode:
  • See tests grouped by project
  • Run all projects or select specific ones
  • Compare results across browsers

Error Messages

When tests fail, UI Mode displays:
  • Full error stack trace
  • Expected vs actual values
  • Diff viewer for complex objects
  • Link to source code line

Console Output

View all console messages:
Console tab shows:
  • All console.* calls from the browser
  • Test runner logs
  • Uncaught exceptions

Network Panel

Inspect all network activity:
  • XHR/Fetch requests
  • Resource loads (images, CSS, JS)
  • API calls
  • WebSocket connections
Click any request to see:
  • Request URL and method
  • Request/response headers
  • Response body
  • Timing information

Using UI Mode for Development

TDD Workflow

new-feature.spec.ts

Debugging Flaky Tests

In UI Mode:
  1. Watch tests run repeatedly
  2. See which attempts fail
  3. Compare traces between passing and failing runs
  4. Identify timing issues or race conditions

UI Mode vs Other Tools

Best for:
  • Active test development
  • Quick feedback loops
  • Comparing browser behaviors
  • Watch mode workflows
Features:
  • Live updates on file save
  • Run specific tests easily
  • Multi-project visualization

Command Line Options

From /home/daytona/workspace/source/packages/playwright/src/program.ts:435, UI Mode supports:

Remote UI Mode

Run UI Mode on a remote server:
Be cautious when exposing UI Mode on a public network. Use SSH tunneling or VPN for secure access.

SSH Tunnel Example

Tips and Tricks

Use Tags

Add @slow or @smoke tags to filter tests quickly

Multiple Windows

Open multiple UI Mode instances for different test suites

Headed Mode

Add --headed to see actual browser windows alongside UI Mode

Save Traces

Click “Export” to save traces for later analysis

See Also