Automate Chrome via chrome-devtools <tool> [args] [flags]. First-time setup: references/installation.md.
Workflow
- Execute: Run tools directly; the daemon starts implicitly (skip
start/status/stopunless changing startup flags). Uselist_pagesto find<pageId>. - Inspect: Run
chrome-devtools take_snapshot <pageId>for element<uid>s (uid=1_1 heading "Example" level="1"). - Act: Pass
<pageId>and<uid>to interaction tools. State persists across commands.
- Required args are positional; optional args use
--flag. Run<tool> --helpfor full options. - Output defaults to Markdown; pass
--output-format=jsonfor JSON. - Full filesystem access is on by default; pass
--allowUnrestrictedPaths=falseonstartto restrict to OS temp dir. - Tool calls time out after 180 seconds; pass
--rpc-timeout=5m(s,morh) for longer calls. A tool's--timeoutdoes not change this limit.
Core Commands
# Pages & navigation
chrome-devtools list_pages
chrome-devtools new_page "https://example.com"
chrome-devtools navigate_page 1 --url "https://example.com" # or --type reload|back
chrome-devtools select_page 1
chrome-devtools close_page 1
# Snapshots & input (<uid> from take_snapshot; most accept --includeSnapshot true)
chrome-devtools take_snapshot 1 # --verbose true --filePath s.txt
chrome-devtools click 1 "uid" # --dblClick true
chrome-devtools fill 1 "uid" "text"
chrome-devtools press_key 1 "Enter"
chrome-devtools type_text 1 "hello" --submitKey "Enter"
# Debugging & inspection
chrome-devtools evaluate_script "() => document.title" --pageId 1
chrome-devtools list_console_messages 1 # --types error
chrome-devtools get_console_message 1 1
chrome-devtools list_network_requests 1 # --resourceTypes fetch
chrome-devtools get_network_request 1 --reqid 1
chrome-devtools take_screenshot 1 # --fullPage true --filePath s.png
# Daemon (only for startup flags or --sessionId=<uuid>)
chrome-devtools start --headless=false # also: status | stop
References (Load on Demand)
- references/debugging-and-network.md: Network mocking, body exports, CSS styles, logpoints, Lighthouse, screencasts, extra input (
hover,drag,handle_dialog,upload_file) and navigation flags. - references/performance-and-memory.md: Performance traces/insights, heap snapshots, and heap-snapshot memory analysis.
- references/emulation-extensions-and-pwa.md: Emulation, viewport resize, extensions, PWAs, experimental tools.
- references/installation.md: One-time installation and troubleshooting.
