Skip to main content

bap watch

Long-running command that subscribes to browser events and streams them to the terminal. Runs until Ctrl+C.

Usage

bap watch
--filter
string
Comma-separated list of event types to show. Options: page, console, network, dialog, download. When omitted, all events are shown.
--format
string
default:"pretty"
Output format: pretty (color-coded, human-readable) or json (NDJSON for piping).

Event Types

Page lifecycle events: load, navigation, close.
14:30:42 PAGE     load https://example.com
14:30:45 PAGE     navigation https://example.com/dashboard
Browser console output with log level (error, warn, log, debug). 14:30:43 CONSOLE ERROR Uncaught TypeError: Cannot read properties of null 14:30:43 CONSOLE WARN Deprecation: Feature X will be removed in v3
HTTP requests and responses. Responses show status codes, color-coded by range.
14:30:42 NET     -> GET  https://api.example.com/users
14:30:42 NET     <- 200  https://api.example.com/users
14:30:43 NET     <- 404  https://api.example.com/missing
14:30:43 NET     x  https://api.example.com/timeout (net::ERR_TIMED_OUT)
Browser dialogs: alert, confirm, prompt. 14:30:44 DIALOG alert: Are you sure you want to leave?
File downloads with state and filename.
14:30:45 DOWNLOAD started report.pdf
14:30:47 DOWNLOAD completed report.pdf

JSON Output

With --format=json, each event is emitted as a single JSON line (NDJSON), suitable for piping to other tools:
{"eventType":"console","level":"error","text":"Uncaught TypeError","timestamp":1711036243000}
{"eventType":"network","type":"response","status":404,"url":"https://api.example.com/missing","timestamp":1711036243500}

Use Cases

Debug failing interactions

Run bap watch --filter=console in one terminal while running BAP commands in another. Console errors often explain why clicks or fills fail.

Monitor API calls

Use bap watch --filter=network to see what API calls a page makes. Useful for understanding SPA behavior.

Pipe to log aggregator

bap watch --format=json | jq '.text' to extract console message text, or pipe to any NDJSON-compatible tool.

Catch unexpected dialogs

Use bap watch --filter=dialog to detect alert/confirm/prompt dialogs that might block automation.
bap watch requires a running browser session. If no session exists, start one first with bap open or bap goto.