|
| 1 | +--- |
| 2 | +name: chrome-devtools-cli-usage |
| 3 | +description: Complete guide for Chrome DevTools CLI - browser automation, debugging, performance analysis, network inspection. Use when automating Chrome, taking screenshots, analyzing performance, monitoring network/console, device emulation, or user mentions chrome-devtools, browser automation, puppeteer, debugging, performance testing, screenshot, network monitoring, console monitoring, or 크롬 개발자도구, 브라우저 자동화, 디버깅, 성능 분석. |
| 4 | +allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion |
| 5 | +version: 1.0.0 |
| 6 | +lastUpdated: 2025-11-08 |
| 7 | +--- |
| 8 | + |
| 9 | +# Chrome DevTools CLI Usage Guide |
| 10 | + |
| 11 | +**chrome-devtools-cli** provides command-line control of Chrome browsers for automation, debugging, and performance analysis. Perfect for developers, scripts, and CI/CD pipelines. |
| 12 | + |
| 13 | +## Quick Installation |
| 14 | + |
| 15 | +```bash |
| 16 | +# Homebrew (macOS/Linux) |
| 17 | +brew install pleaseai/tap/chrome-devtools-cli |
| 18 | + |
| 19 | +# Quick install script (auto-detects platform) |
| 20 | +curl -fsSL https://raw.githubusercontent.com/pleaseai/chrome-devtools-cli/main/install.sh | bash |
| 21 | + |
| 22 | +# npm/Bun |
| 23 | +npm install -g @pleaseai/chrome-devtools-cli |
| 24 | +``` |
| 25 | + |
| 26 | +> **Detailed installation**: See [references/INSTALLATION.md](references/INSTALLATION.md) |
| 27 | +
|
| 28 | +## Quick Start |
| 29 | + |
| 30 | +### Basic Navigation |
| 31 | + |
| 32 | +```bash |
| 33 | +# Open a new page |
| 34 | +chrome-devtools nav new-page --url https://example.com |
| 35 | + |
| 36 | +# Navigate current page |
| 37 | +chrome-devtools nav navigate --url https://google.com |
| 38 | + |
| 39 | +# List all pages |
| 40 | +chrome-devtools nav list-pages |
| 41 | +``` |
| 42 | + |
| 43 | +### Screenshots |
| 44 | + |
| 45 | +```bash |
| 46 | +# Standard screenshot |
| 47 | +chrome-devtools debug screenshot --path screenshot.png |
| 48 | + |
| 49 | +# Full page screenshot |
| 50 | +chrome-devtools debug screenshot --path screenshot.png --full-page |
| 51 | +``` |
| 52 | + |
| 53 | +### Performance Analysis |
| 54 | + |
| 55 | +```bash |
| 56 | +# Quick performance analysis |
| 57 | +chrome-devtools perf analyze --url https://example.com --format json |
| 58 | +``` |
| 59 | + |
| 60 | +### Network Monitoring |
| 61 | + |
| 62 | +```bash |
| 63 | +# Start monitoring |
| 64 | +chrome-devtools network start-monitoring |
| 65 | + |
| 66 | +# List requests (TOON format for 58.9% token reduction) |
| 67 | +chrome-devtools network list-requests --format toon |
| 68 | +``` |
| 69 | + |
| 70 | +## Essential Commands |
| 71 | + |
| 72 | +### Input Automation |
| 73 | + |
| 74 | +```bash |
| 75 | +# Click element |
| 76 | +chrome-devtools input click --uid <element-uid> |
| 77 | + |
| 78 | +# Fill input |
| 79 | +chrome-devtools input fill --uid input-email --value "user@example.com" |
| 80 | + |
| 81 | +# Press keys |
| 82 | +chrome-devtools input press-key --key Enter |
| 83 | + |
| 84 | +# Handle dialogs |
| 85 | +chrome-devtools input handle-dialog --action accept |
| 86 | +``` |
| 87 | + |
| 88 | +### Page Navigation |
| 89 | + |
| 90 | +```bash |
| 91 | +# Create new page |
| 92 | +chrome-devtools nav new-page --url <url> |
| 93 | + |
| 94 | +# Wait for element |
| 95 | +chrome-devtools nav wait-for --selector "#element" |
| 96 | + |
| 97 | +# Wait for text |
| 98 | +chrome-devtools nav wait-for --text "Welcome" |
| 99 | +``` |
| 100 | + |
| 101 | +### Device Emulation |
| 102 | + |
| 103 | +```bash |
| 104 | +# Emulate device |
| 105 | +chrome-devtools emulate device --name "iPhone 13" |
| 106 | + |
| 107 | +# Custom viewport |
| 108 | +chrome-devtools emulate resize --width 1920 --height 1080 |
| 109 | +``` |
| 110 | + |
| 111 | +### Debugging |
| 112 | + |
| 113 | +```bash |
| 114 | +# Start console monitoring |
| 115 | +chrome-devtools debug start-console-monitoring |
| 116 | + |
| 117 | +# List console messages |
| 118 | +chrome-devtools debug list-console --types error,warning |
| 119 | + |
| 120 | +# Evaluate JavaScript |
| 121 | +chrome-devtools debug evaluate --script "document.title" |
| 122 | + |
| 123 | +# Take screenshot |
| 124 | +chrome-devtools debug screenshot --path screenshot.png --full-page |
| 125 | +``` |
| 126 | + |
| 127 | +### Performance |
| 128 | + |
| 129 | +```bash |
| 130 | +# Start trace |
| 131 | +chrome-devtools perf start-trace |
| 132 | + |
| 133 | +# Stop trace |
| 134 | +chrome-devtools perf stop-trace --output trace.json |
| 135 | + |
| 136 | +# Automated analysis |
| 137 | +chrome-devtools perf analyze --url <url> --duration 10000 --format json |
| 138 | +``` |
| 139 | + |
| 140 | +### Network |
| 141 | + |
| 142 | +```bash |
| 143 | +# Start monitoring |
| 144 | +chrome-devtools network start-monitoring |
| 145 | + |
| 146 | +# List requests |
| 147 | +chrome-devtools network list-requests --format toon |
| 148 | + |
| 149 | +# Get request details |
| 150 | +chrome-devtools network get-request --id <request-id> |
| 151 | + |
| 152 | +# Clear history |
| 153 | +chrome-devtools network clear |
| 154 | +``` |
| 155 | + |
| 156 | +## Global Options |
| 157 | + |
| 158 | +Available on all commands: |
| 159 | + |
| 160 | +```bash |
| 161 | +chrome-devtools [options] <command> [command-options] |
| 162 | +``` |
| 163 | + |
| 164 | +**Connection:** |
| 165 | + |
| 166 | +- `--browser-url <url>` - Connect to existing Chrome instance |
| 167 | +- `--ws-endpoint <endpoint>` - WebSocket endpoint |
| 168 | + |
| 169 | +**Browser:** |
| 170 | + |
| 171 | +- `--headless` - Run without GUI |
| 172 | +- `--isolated` - Temporary profile |
| 173 | +- `--channel <channel>` - Chrome channel (stable, beta, dev, canary) |
| 174 | + |
| 175 | +**Output:** |
| 176 | + |
| 177 | +- `--format <format>` - json, toon, or text (default) |
| 178 | + |
| 179 | +**Display:** |
| 180 | + |
| 181 | +- `--viewport <size>` - Initial viewport (e.g., 1280x720) |
| 182 | + |
| 183 | +> **Complete options**: See [references/COMMANDS.md](references/COMMANDS.md) |
| 184 | +
|
| 185 | +## Output Formats |
| 186 | + |
| 187 | +### Text (Default) |
| 188 | + |
| 189 | +Human-readable console output. |
| 190 | + |
| 191 | +### JSON |
| 192 | + |
| 193 | +Standard JSON for programmatic use. |
| 194 | + |
| 195 | +### TOON (Token-Optimized) |
| 196 | + |
| 197 | +58.9% token reduction vs JSON - ideal for LLM workflows. |
| 198 | + |
| 199 | +```bash |
| 200 | +chrome-devtools network list-requests --format toon |
| 201 | +``` |
| 202 | + |
| 203 | +## Common Workflows |
| 204 | + |
| 205 | +### Complete Automation |
| 206 | + |
| 207 | +```bash |
| 208 | +# Start monitoring |
| 209 | +chrome-devtools debug start-console-monitoring |
| 210 | +chrome-devtools network start-monitoring |
| 211 | + |
| 212 | +# Navigate and interact |
| 213 | +chrome-devtools nav new-page --url https://example.com |
| 214 | +chrome-devtools input fill --uid input-email --value "user@example.com" |
| 215 | +chrome-devtools input click --uid button-submit |
| 216 | + |
| 217 | +# Capture results |
| 218 | +chrome-devtools debug screenshot --path result.png |
| 219 | +chrome-devtools network list-requests --format toon |
| 220 | + |
| 221 | +# Cleanup |
| 222 | +chrome-devtools close |
| 223 | +``` |
| 224 | + |
| 225 | +### CI/CD Integration |
| 226 | + |
| 227 | +```bash |
| 228 | +#!/bin/bash |
| 229 | +# Headless browser testing |
| 230 | + |
| 231 | +chrome-devtools --headless nav new-page --url https://staging.example.com |
| 232 | +chrome-devtools --headless debug screenshot --path ci-screenshot.png |
| 233 | +chrome-devtools --headless perf analyze --url https://staging.example.com --format json > perf.json |
| 234 | +chrome-devtools close |
| 235 | +``` |
| 236 | + |
| 237 | +### Mobile Testing |
| 238 | + |
| 239 | +```bash |
| 240 | +# Test on different devices |
| 241 | +chrome-devtools emulate device --name "iPhone 13" |
| 242 | +chrome-devtools nav new-page --url https://example.com |
| 243 | +chrome-devtools debug screenshot --path mobile-iphone.png |
| 244 | + |
| 245 | +chrome-devtools emulate device --name "iPad Pro" |
| 246 | +chrome-devtools nav navigate --url https://example.com |
| 247 | +chrome-devtools debug screenshot --path mobile-ipad.png |
| 248 | +``` |
| 249 | + |
| 250 | +> **More workflows**: See [references/WORKFLOWS.md](references/WORKFLOWS.md) |
| 251 | +
|
| 252 | +## Advanced Usage |
| 253 | + |
| 254 | +### Connect to Existing Chrome |
| 255 | + |
| 256 | +```bash |
| 257 | +# Start Chrome with remote debugging |
| 258 | +/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \ |
| 259 | + --remote-debugging-port=9222 \ |
| 260 | + --user-data-dir=/tmp/chrome-profile |
| 261 | + |
| 262 | +# Connect via CLI |
| 263 | +chrome-devtools --browser-url http://127.0.0.1:9222 nav list-pages |
| 264 | +``` |
| 265 | + |
| 266 | +### Headless Mode |
| 267 | + |
| 268 | +```bash |
| 269 | +chrome-devtools --headless --viewport 1920x1080 nav new-page --url https://example.com |
| 270 | +``` |
| 271 | + |
| 272 | +### Programmatic API |
| 273 | + |
| 274 | +```typescript |
| 275 | +import { closeBrowser, navigatePage, takeScreenshot } from '@pleaseai/chrome-devtools-cli' |
| 276 | + |
| 277 | +await navigatePage({ url: 'https://example.com' }) |
| 278 | +await takeScreenshot({ path: 'screenshot.png', fullPage: true }) |
| 279 | +await closeBrowser() |
| 280 | +``` |
| 281 | + |
| 282 | +> **Advanced features**: See [references/ADVANCED-USAGE.md](references/ADVANCED-USAGE.md) |
| 283 | +
|
| 284 | +## Key Features |
| 285 | + |
| 286 | +- **Input Automation** - Click, hover, fill forms, keyboard, drag-drop |
| 287 | +- **Navigation** - Multi-page management, URL navigation, wait conditions |
| 288 | +- **Emulation** - Device emulation, viewport resizing |
| 289 | +- **Performance** - Trace recording, performance analysis |
| 290 | +- **Network** - Request monitoring and inspection |
| 291 | +- **Debugging** - Console monitoring, JavaScript evaluation, screenshots |
| 292 | +- **Multiple Formats** - JSON, TOON (58.9% token reduction), text |
| 293 | +- **Flexible Connection** - Launch new or connect to existing Chrome |
| 294 | + |
| 295 | +## Requirements |
| 296 | + |
| 297 | +- Node.js v20.19+ (LTS) |
| 298 | +- Chrome stable version |
| 299 | +- npm or Bun |
| 300 | + |
| 301 | +## Architecture |
| 302 | + |
| 303 | +Built on [Puppeteer](https://pptr.dev/) with CLI framework and output formatting utilities. |
| 304 | + |
| 305 | +## Tips and Best Practices |
| 306 | + |
| 307 | +1. **Use TOON format** for LLM workflows (58.9% token reduction) |
| 308 | +2. **Start monitoring before navigation** to capture all requests |
| 309 | +3. **Use headless mode** for CI/CD pipelines |
| 310 | +4. **Use isolated mode** for reproducible tests |
| 311 | +5. **Connect to existing Chrome** for debugging live instances |
| 312 | + |
| 313 | +## Reference Documentation |
| 314 | + |
| 315 | +- [Installation Guide](references/INSTALLATION.md) - All installation methods |
| 316 | +- [Commands Reference](references/COMMANDS.md) - Complete command documentation |
| 317 | +- [Advanced Usage](references/ADVANCED-USAGE.md) - Advanced features and patterns |
| 318 | +- [Common Workflows](references/WORKFLOWS.md) - Practical workflow examples |
| 319 | + |
| 320 | +## Resources |
| 321 | + |
| 322 | +- [GitHub Repository](https://github.com/pleaseai/chrome-devtools-cli) |
| 323 | +- [npm Package](https://www.npmjs.com/package/@pleaseai/chrome-devtools-cli) |
| 324 | +- [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp) |
| 325 | +- [Puppeteer Docs](https://pptr.dev/) |
| 326 | + |
| 327 | +--- |
| 328 | + |
| 329 | +**Version**: 1.0.0 |
| 330 | +**Author**: Minsu Lee ([@amondnet](https://github.com/amondnet)) |
| 331 | +**License**: MIT |
0 commit comments