chrome-cdp-cli 1.8.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -144,109 +144,267 @@ Examples:
144
144
  }
145
145
  generateClaudeSkill() {
146
146
  return {
147
- name: 'cdp-cli',
148
- description: 'Chrome browser automation and testing using DevTools Protocol. Use when user needs to control Chrome browser, execute JavaScript, take screenshots, interact with elements, monitor console/network, upload files, handle dialogs, or perform comprehensive web automation tasks.',
149
- instructions: `# Chrome Browser Automation
147
+ name: 'cdp-cli-enhanced',
148
+ description: 'Advanced Chrome browser automation using enhanced DevTools CLI v2.0 with configuration management, error handling, contextual help, and comprehensive testing workflows. Use for complex web automation, testing, form handling, performance monitoring, and CI/CD integration.',
149
+ instructions: `# Enhanced Chrome Browser Automation
150
150
 
151
151
  ## Instructions
152
- Use this skill when the user needs to:
153
- - Execute JavaScript code in Chrome browser
154
- - Take screenshots of web pages and DOM snapshots
155
- - Interact with page elements (click, hover, fill forms, drag & drop)
156
- - Simulate keyboard input and handle file uploads
157
- - Wait for elements and handle browser dialogs
158
- - Monitor console messages and network requests
159
- - Perform comprehensive web automation and testing
152
+ Use this skill when the user needs advanced browser automation with:
153
+ - Configuration-driven workflows with profiles and aliases
154
+ - Enhanced error handling with contextual help and recovery
155
+ - Comprehensive testing with evidence capture
156
+ - Performance monitoring and metrics collection
157
+ - CI/CD integration with structured reporting
158
+ - Plugin-based extensibility for custom commands
160
159
 
161
- ## Complete Command List
160
+ ## Enhanced CLI Features (v2.0)
162
161
 
163
- ### JavaScript Execution
164
- - **eval**: Execute JavaScript code in browser context
165
- \`chrome-cdp-cli eval "document.title"\`
166
- \`chrome-cdp-cli eval "fetch('/api/data').then(r => r.json())"\`
162
+ ### Configuration Management
163
+ Use YAML/JSON configuration files with profiles for different environments:
167
164
 
168
- ### Visual Capture
169
- - **screenshot**: Capture page screenshots
170
- \`chrome-cdp-cli screenshot --filename page.png\`
171
- - **snapshot**: Capture complete DOM snapshots with layout info
172
- \`chrome-cdp-cli snapshot --filename dom-snapshot.json\`
165
+ \`\`\`yaml
166
+ # .chrome-cdp-cli.yaml
167
+ profiles:
168
+ development:
169
+ host: localhost
170
+ port: 9222
171
+ debug: true
172
+ verbose: true
173
+
174
+ testing:
175
+ host: test-chrome
176
+ port: 9223
177
+ quiet: true
178
+ outputFormat: json
179
+
180
+ production:
181
+ host: prod-chrome
182
+ port: 9222
183
+ quiet: true
184
+ timeout: 60000
185
+
186
+ aliases:
187
+ health-check: eval "document.readyState === 'complete'"
188
+ capture-evidence: screenshot --filename evidence-$(date +%s).png
189
+ check-console: console --types error
190
+
191
+ commands:
192
+ screenshot:
193
+ defaults:
194
+ format: png
195
+ quality: 95
196
+ fullPage: true
197
+ \`\`\`
173
198
 
174
- ### Element Interaction
175
- - **click**: Click on elements using CSS selectors
176
- \`chrome-cdp-cli click "#submit-button"\`
177
- - **hover**: Hover over elements
178
- \`chrome-cdp-cli hover "#dropdown-trigger"\`
179
- - **fill**: Fill form fields with text
180
- \`chrome-cdp-cli fill "#username" "john@example.com"\`
181
- - **fill_form**: Fill multiple form fields at once
182
- \`chrome-cdp-cli fill_form '{"#username": "john", "#password": "secret"}'\`
199
+ ### Enhanced Global Options
200
+ - \`--profile <name>\`: Use configuration profile
201
+ - \`--config <path>\`: Specify configuration file
202
+ - \`--debug\`: Enable debug mode with detailed logging
203
+ - \`--verbose\`: Enable verbose output with timing
204
+ - \`--quiet\`: Silent mode for CI/CD
205
+ - \`--format <json|text|yaml>\`: Enhanced output formats
206
+ - \`--help topic <topic>\`: Get contextual help on topics
207
+
208
+ ### Advanced Error Handling
209
+ The CLI provides contextual help and suggestions when commands fail:
210
+
211
+ \`\`\`bash
212
+ # Automatic contextual help on errors
213
+ chrome-cdp-cli click "#nonexistent-element"
214
+ # Shows: selector validation tips, alternatives, related help topics
215
+
216
+ # Debug mode for detailed error information
217
+ chrome-cdp-cli --debug --verbose click "#problematic-element"
218
+ # Shows: execution logs, CDP messages, timing information
219
+ \`\`\`
220
+
221
+ ## Complete Command Reference
222
+
223
+ ### JavaScript Execution
224
+ - **eval**: Execute JavaScript code with enhanced error handling
225
+ \`chrome-cdp-cli --profile development eval "document.title"\`
226
+ \`chrome-cdp-cli --format json eval "performance.timing"\`
227
+ \`chrome-cdp-cli eval --file automation-script.js\`
228
+
229
+ ### Visual Capture with Enhanced Options
230
+ - **screenshot**: Advanced screenshot capture
231
+ \`chrome-cdp-cli --profile testing screenshot --filename test-result.png\`
232
+ \`chrome-cdp-cli screenshot --full-page --format jpeg --quality 90\`
233
+ - **snapshot**: Complete DOM snapshots with metadata
234
+ \`chrome-cdp-cli --format json snapshot --filename dom-analysis.json\`
235
+
236
+ ### Enhanced Element Interaction
237
+ - **click**: Click with retry and error recovery
238
+ \`chrome-cdp-cli --debug click "#submit-button"\`
239
+ \`chrome-cdp-cli click ".slow-loading-button" --timeout 15000\`
240
+ - **hover**: Hover with timing control
241
+ \`chrome-cdp-cli hover "#dropdown-trigger" --timeout 5000\`
242
+ - **fill**: Form filling with validation
243
+ \`chrome-cdp-cli fill "#username" "john@example.com" --no-clear\`
244
+ - **fill_form**: Batch form operations with error handling
245
+ \`chrome-cdp-cli fill_form --fields-file form-data.json --continue-on-error\`
183
246
 
184
247
  ### Advanced Interactions
185
- - **drag**: Perform drag and drop operations
186
- \`chrome-cdp-cli drag "#draggable" "#dropzone"\`
187
- - **press_key**: Simulate keyboard input with modifiers
188
- \`chrome-cdp-cli press_key "Enter"\`
189
- \`chrome-cdp-cli press_key "a" --modifiers Ctrl\`
190
- - **upload_file**: Upload files to file input elements
248
+ - **drag**: Enhanced drag and drop
249
+ \`chrome-cdp-cli --verbose drag "#draggable" "#dropzone"\`
250
+ - **press_key**: Keyboard simulation with element targeting
251
+ \`chrome-cdp-cli press_key "Enter" --selector "#search-input"\`
252
+ \`chrome-cdp-cli press_key "s" --modifiers Ctrl,Shift\`
253
+ - **upload_file**: File upload with validation
191
254
  \`chrome-cdp-cli upload_file "input[type='file']" "./document.pdf"\`
192
- - **wait_for**: Wait for elements to appear or meet conditions
193
- \`chrome-cdp-cli wait_for "#loading" --condition hidden\`
255
+ - **wait_for**: Advanced waiting with conditions
256
+ \`chrome-cdp-cli wait_for "#loading" --condition hidden --timeout 30000\`
194
257
  \`chrome-cdp-cli wait_for "#submit-btn" --condition enabled\`
195
- - **handle_dialog**: Handle browser dialogs (alert, confirm, prompt)
196
- \`chrome-cdp-cli handle_dialog accept\`
197
- \`chrome-cdp-cli handle_dialog accept --text "user input"\`
258
+ - **handle_dialog**: Dialog handling with text input
259
+ \`chrome-cdp-cli handle_dialog accept --text "confirmation text"\`
260
+
261
+ ### Enhanced Monitoring
262
+ - **console**: Console monitoring with filtering
263
+ \`chrome-cdp-cli --format json console --latest\`
264
+ \`chrome-cdp-cli console --types error,warn\`
265
+ - **network**: Network monitoring with filters
266
+ \`chrome-cdp-cli --format json network --latest\`
267
+ \`chrome-cdp-cli network --filter '{"methods":["POST"],"statusCodes":[200,201]}'\`
268
+
269
+ ### Help System
270
+ - **help**: Comprehensive help with topics
271
+ \`chrome-cdp-cli help\` - General help with categorized commands
272
+ \`chrome-cdp-cli help eval\` - Command-specific help with examples
273
+ \`chrome-cdp-cli help topic configuration\` - Configuration management
274
+ \`chrome-cdp-cli help topic selectors\` - CSS selector guide
275
+ \`chrome-cdp-cli help topic automation\` - Best practices
276
+ \`chrome-cdp-cli help topic debugging\` - Troubleshooting guide
277
+
278
+ ## Enhanced Automation Workflows
279
+
280
+ ### Configuration-Driven Testing
281
+ \`\`\`bash
282
+ # Load testing profile
283
+ chrome-cdp-cli --profile testing --config test-config.yaml
284
+
285
+ # Execute test suite with error recovery
286
+ chrome-cdp-cli eval --file test-suite.js || {
287
+ echo "Test failed, capturing evidence..."
288
+ chrome-cdp-cli capture-evidence
289
+ chrome-cdp-cli check-console
290
+ exit 1
291
+ }
198
292
 
199
- ### Monitoring
200
- - **get_console_message**: Get latest console message
201
- \`chrome-cdp-cli get_console_message\`
202
- - **list_console_messages**: List all console messages
203
- \`chrome-cdp-cli list_console_messages --type error\`
204
- - **get_network_request**: Get latest network request
205
- \`chrome-cdp-cli get_network_request\`
206
- - **list_network_requests**: List all network requests
207
- \`chrome-cdp-cli list_network_requests --method POST\`
293
+ # Generate structured report
294
+ chrome-cdp-cli --format json eval "generateTestReport()" > test-results.json
295
+ \`\`\`
208
296
 
209
- ### IDE Integration
210
- - **install_cursor_command**: Install Cursor IDE commands
211
- \`chrome-cdp-cli install_cursor_command\`
212
- - **install_claude_skill**: Install Claude Code skills
213
- \`chrome-cdp-cli install_claude_skill --skill-type personal\`
214
-
215
- ## Common Automation Patterns
216
-
217
- ### Form Testing Workflow
218
- 1. Wait for form: \`wait_for "#login-form" --condition visible\`
219
- 2. Fill fields: \`fill "#email" "test@example.com"\`
220
- 3. Submit: \`click "#submit-button"\`
221
- 4. Verify: \`wait_for "#success" --condition visible\`
222
- 5. Capture: \`screenshot --filename result.png\`
223
-
224
- ### File Upload Testing
225
- 1. Trigger upload: \`click "#upload-button"\`
226
- 2. Upload file: \`upload_file "input[type='file']" "./test.pdf"\`
227
- 3. Wait for completion: \`wait_for ".upload-success" --condition visible\`
228
- 4. Verify: \`eval "document.querySelector('.file-name').textContent"\`
297
+ ### Performance Monitoring Workflow
298
+ \`\`\`bash
299
+ # Set up performance monitoring
300
+ chrome-cdp-cli --profile performance --verbose
301
+
302
+ # Navigate and collect metrics
303
+ chrome-cdp-cli eval "window.location.href = 'https://example.com'"
304
+ chrome-cdp-cli wait_for "#main-content" --timeout 30000
305
+
306
+ # Collect comprehensive performance data
307
+ chrome-cdp-cli --format json eval "
308
+ const timing = performance.timing;
309
+ const navigation = performance.getEntriesByType('navigation')[0];
310
+ const resources = performance.getEntriesByType('resource');
311
+
312
+ return {
313
+ loadTime: timing.loadEventEnd - timing.navigationStart,
314
+ domContentLoaded: timing.domContentLoadedEventEnd - timing.navigationStart,
315
+ firstPaint: navigation.loadEventEnd,
316
+ resourceCount: resources.length,
317
+ resourceSizes: resources.map(r => ({name: r.name, size: r.transferSize}))
318
+ };
319
+ " > performance-metrics.json
320
+ \`\`\`
229
321
 
230
- ### Dialog Handling
231
- 1. Trigger action: \`click "#delete-button"\`
232
- 2. Handle confirmation: \`handle_dialog accept\`
233
- 3. Wait for result: \`wait_for "#deleted-message" --condition visible\`
322
+ ### Advanced Form Testing
323
+ \`\`\`bash
324
+ # Configure for form testing
325
+ chrome-cdp-cli --profile development --debug
234
326
 
235
- ### Keyboard Navigation
236
- 1. Focus element: \`click "#search-input"\`
237
- 2. Type text: \`press_key "search term"\`
238
- 3. Use shortcuts: \`press_key "a" --modifiers Ctrl\` (select all)
239
- 4. Submit: \`press_key "Enter"\`
327
+ # Batch form filling with comprehensive error handling
328
+ chrome-cdp-cli fill_form --fields-file form-test-data.json --continue-on-error --timeout 15000
240
329
 
241
- ## Prerequisites
242
- Chrome browser must be running with DevTools enabled:
243
- \`chrome --remote-debugging-port=9222\`
330
+ # Validate form submission with evidence capture
331
+ chrome-cdp-cli click "#submit-button"
332
+ chrome-cdp-cli wait_for ".success-message, .error-message" --timeout 10000
333
+
334
+ # Capture validation results
335
+ chrome-cdp-cli --format json eval "
336
+ const form = document.querySelector('#test-form');
337
+ const errors = Array.from(form.querySelectorAll('.error')).map(e => e.textContent);
338
+ const success = document.querySelector('.success-message');
339
+ return {
340
+ errors,
341
+ success: !!success,
342
+ timestamp: new Date().toISOString(),
343
+ formData: new FormData(form)
344
+ };
345
+ " > validation-results.json
346
+ \`\`\`
244
347
 
245
- ## Global Options
246
- All commands support:
247
- - \`--host <hostname>\`: Chrome host (default: localhost)
248
- - \`--port <number>\`: Chrome port (default: 9222)
249
- - \`--format <json|text>\`: Output format
348
+ ### CI/CD Integration
349
+ \`\`\`bash
350
+ # Headless Chrome setup for CI
351
+ chrome --headless --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-ci &
352
+
353
+ # Execute tests with CI profile
354
+ chrome-cdp-cli --profile ci --quiet eval --file ci-test-suite.js
355
+
356
+ # Generate JUnit-compatible reports
357
+ chrome-cdp-cli --format json eval "generateJUnitReport()" > test-results.xml
358
+
359
+ # Capture evidence on failures
360
+ if [ $? -ne 0 ]; then
361
+ chrome-cdp-cli screenshot --filename failure-evidence.png
362
+ chrome-cdp-cli console --types error > console-errors.json
363
+ fi
364
+ \`\`\`
365
+
366
+ ## Enhanced Prerequisites
367
+
368
+ ### Chrome Setup with Security
369
+ \`\`\`bash
370
+ # Always use --user-data-dir for security (required)
371
+ chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug
372
+
373
+ # Headless mode for CI/CD
374
+ chrome --headless --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-ci
375
+
376
+ # With additional automation flags
377
+ chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug --no-first-run --no-default-browser-check
378
+ \`\`\`
379
+
380
+ ### Configuration File Setup
381
+ Create \`.chrome-cdp-cli.yaml\` in your project root with appropriate profiles for your environments.
382
+
383
+ ## Documentation and Support
384
+
385
+ ### Available Help Topics
386
+ - \`configuration\` - YAML configuration, profiles, environment setup
387
+ - \`selectors\` - CSS selector guide and best practices
388
+ - \`automation\` - Browser automation workflows and patterns
389
+ - \`debugging\` - Troubleshooting and error resolution
390
+ - \`scripting\` - Integration with scripts and CI/CD
391
+ - \`performance\` - Performance monitoring and optimization
392
+
393
+ ### Contextual Help
394
+ Commands automatically provide contextual help when they fail, including:
395
+ - Specific error analysis and suggestions
396
+ - Alternative approaches and workarounds
397
+ - Related commands and help topics
398
+ - Configuration recommendations
399
+
400
+ ### Plugin System
401
+ Extend functionality with plugins:
402
+ \`chrome-cdp-cli --plugin-dir ./plugins custom-command\`
403
+
404
+ For comprehensive documentation, see:
405
+ - Configuration Guide: docs/CONFIGURATION.md
406
+ - Plugin Development: docs/PLUGIN_DEVELOPMENT.md
407
+ - Advanced Help Topics: \`chrome-cdp-cli help topic <topic>\`
250
408
  - \`--verbose\`: Enable detailed logging
251
409
  - \`--timeout <ms>\`: Operation timeout`,
252
410
  allowedTools: ['Execute', 'Read', 'Write']
@@ -256,6 +414,9 @@ All commands support:
256
414
  const frontmatter = `---
257
415
  name: ${skill.name}
258
416
  description: ${skill.description}
417
+ version: 2.0.0
418
+ category: browser-automation
419
+ tools: [chrome-cdp-cli]
259
420
  ${skill.allowedTools ? `allowedTools: [${skill.allowedTools.map(t => `"${t}"`).join(', ')}]` : ''}
260
421
  ---
261
422
 
@@ -408,18 +569,18 @@ chrome-cdp-cli snapshot --filename form-state.json
408
569
 
409
570
  ### Console Messages
410
571
  \`\`\`bash
411
- chrome-cdp-cli get_console_message
412
- chrome-cdp-cli list_console_messages
413
- chrome-cdp-cli list_console_messages --type error
414
- chrome-cdp-cli list_console_messages --type warn
572
+ chrome-cdp-cli console --latest
573
+ chrome-cdp-cli console
574
+ chrome-cdp-cli console --types error
575
+ chrome-cdp-cli console --types warn
415
576
  \`\`\`
416
577
 
417
578
  ### Network Requests
418
579
  \`\`\`bash
419
- chrome-cdp-cli get_network_request
420
- chrome-cdp-cli list_network_requests
421
- chrome-cdp-cli list_network_requests --method POST
422
- chrome-cdp-cli list_network_requests --method GET
580
+ chrome-cdp-cli network --latest
581
+ chrome-cdp-cli network
582
+ chrome-cdp-cli network --filter '{"methods":["POST"]}'
583
+ chrome-cdp-cli network --filter '{"methods":["GET"]}'
423
584
  \`\`\`
424
585
 
425
586
  ## Complete Workflow Examples
@@ -443,7 +604,7 @@ chrome-cdp-cli wait_for "#dashboard" --condition visible --timeout 10000
443
604
  chrome-cdp-cli screenshot --filename login-success.png
444
605
 
445
606
  # 6. Check for any errors
446
- chrome-cdp-cli list_console_messages --type error
607
+ chrome-cdp-cli console --types error
447
608
  \`\`\`
448
609
 
449
610
  ### File Upload Workflow
@@ -756,39 +917,25 @@ Handle browser dialogs (alert, confirm, prompt).
756
917
 
757
918
  ### Monitoring
758
919
 
759
- #### get_console_message
760
- Get the latest console message.
761
-
762
- **Syntax:** \`chrome-cdp-cli get_console_message [options]\`
763
-
764
- **Options:**
765
- - \`--type <log|info|warn|error>\`: Filter by message type
766
-
767
- #### list_console_messages
768
- List all console messages.
769
-
770
- **Syntax:** \`chrome-cdp-cli list_console_messages [options]\`
771
-
772
- **Options:**
773
- - \`--type <log|info|warn|error>\`: Filter by message type
774
- - \`--limit <number>\`: Maximum number of messages to return
775
-
776
- #### get_network_request
777
- Get the latest network request.
920
+ #### console
921
+ List console messages or get the latest message.
778
922
 
779
- **Syntax:** \`chrome-cdp-cli get_network_request [options]\`
923
+ **Syntax:** \`chrome-cdp-cli console [options]\`
780
924
 
781
925
  **Options:**
782
- - \`--method <GET|POST|PUT|DELETE>\`: Filter by HTTP method
926
+ - \`--latest\`: Get only the latest message
927
+ - \`--types <types>\`: Filter by message types (comma-separated: log,info,warn,error,debug)
928
+ - \`--textPattern <pattern>\`: Filter by text pattern (regex)
929
+ - \`--maxMessages <count>\`: Maximum number of messages to return
783
930
 
784
- #### list_network_requests
785
- List all network requests.
931
+ #### network
932
+ List network requests or get the latest request.
786
933
 
787
- **Syntax:** \`chrome-cdp-cli list_network_requests [options]\`
934
+ **Syntax:** \`chrome-cdp-cli network [options]\`
788
935
 
789
936
  **Options:**
790
- - \`--method <GET|POST|PUT|DELETE>\`: Filter by HTTP method
791
- - \`--limit <number>\`: Maximum number of requests to return
937
+ - \`--latest\`: Get only the latest request
938
+ - \`--filter <json>\`: Filter requests (JSON string with methods, urlPattern, statusCodes, etc.)
792
939
 
793
940
  ### IDE Integration
794
941
 
@@ -950,7 +1097,7 @@ Element is present and disabled (for form elements):
950
1097
  chrome-cdp-cli screenshot --filename test-result.png
951
1098
 
952
1099
  # Check for errors
953
- chrome-cdp-cli list_console_messages --type error
1100
+ chrome-cdp-cli console --types error
954
1101
  \`\`\`
955
1102
 
956
1103
  ### Automated Testing Script
@@ -995,7 +1142,7 @@ chrome-cdp-cli screenshot --filename final-state.png
995
1142
  chrome-cdp-cli snapshot --filename final-dom.json
996
1143
 
997
1144
  # Check for errors
998
- ERROR_COUNT=$(chrome-cdp-cli list_console_messages --type error | jq length)
1145
+ ERROR_COUNT=$(chrome-cdp-cli console --types error | jq length)
999
1146
  if [ "$ERROR_COUNT" -gt 0 ]; then
1000
1147
  echo "Test failed: $ERROR_COUNT console errors found"
1001
1148
  exit 1