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
Open in Browser Tab
Instead of a desktop window, open UI Mode in your default browser: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
- 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 pressCtrl+Shift+R (Windows/Linux) or Cmd+Shift+R (Mac).
Run Single Test
example.spec.ts
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:- Use project filter dropdown
- Select Chromium, Firefox, or WebKit
- Run tests
Time Travel Debugging
One of UI Mode’s most powerful features:How It Works
- Run a test in UI Mode
- Click any action in the timeline
- See the exact state of the page at that moment
- Hover over elements to inspect them
- Copy locators from the DOM
Debugging Failed Tests
- Test fails and stops at the assertion
- Click on the failed action
- See the screenshot showing what was actually displayed
- Check the Console tab for errors
- Inspect the Network tab for failed requests
- Copy the correct locator
Live Trace View
UI Mode records traces automatically:Unlike the Trace Viewer which analyzes saved traces, UI Mode provides live trace viewing as tests run.
Pick Locator Tool
Build selectors interactively:- Click “Pick Locator” button
- Hover over elements in the page snapshot
- Click an element
- UI Mode generates the best locator:
- 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
| Shortcut | Action |
|---|---|
Ctrl/Cmd+Shift+R | Run all tests |
Ctrl/Cmd+R | Re-run last test |
Ctrl/Cmd+F | Focus search box |
Ctrl/Cmd+Shift+C | Pick locator |
Esc | Stop running tests |
F5 | Reload UI Mode |
UI Mode Features
Multiple Projects
Run tests across browsers:playwright.config.ts
- 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:- 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
- 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
- Watch tests run repeatedly
- See which attempts fail
- Compare traces between passing and failing runs
- Identify timing issues or race conditions
UI Mode vs Other Tools
- UI Mode
- Inspector
- Trace Viewer
Best for:
- Active test development
- Quick feedback loops
- Comparing browser behaviors
- Watch mode workflows
- 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:SSH Tunnel Example
Tips and Tricks
Use Tags
Add
@slow or @smoke tags to filter tests quicklyMultiple Windows
Open multiple UI Mode instances for different test suites
Headed Mode
Add
--headed to see actual browser windows alongside UI ModeSave Traces
Click “Export” to save traces for later analysis
See Also
- Inspector - Step through tests with breakpoints
- Trace Viewer - Analyze saved trace files
- Code Generator - Generate test code interactively
