chrome-cdp-cli 1.2.4 → 1.3.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.
- package/README.md +347 -35
- package/dist/cli/CLIApplication.js +9 -0
- package/dist/cli/CommandRouter.js +6 -0
- package/dist/handlers/ClickHandler.js +241 -0
- package/dist/handlers/DragHandler.js +267 -0
- package/dist/handlers/FillFormHandler.js +245 -0
- package/dist/handlers/FillHandler.js +354 -0
- package/dist/handlers/HandleDialogHandler.js +197 -0
- package/dist/handlers/HoverHandler.js +268 -0
- package/dist/handlers/InstallClaudeSkillHandler.js +632 -57
- package/dist/handlers/InstallCursorCommandHandler.js +146 -73
- package/dist/handlers/PressKeyHandler.js +337 -0
- package/dist/handlers/UploadFileHandler.js +325 -0
- package/dist/handlers/WaitForHandler.js +331 -0
- package/dist/handlers/index.js +9 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -49,6 +49,7 @@ A command-line tool designed specifically for Large Language Models (LLMs) and A
|
|
|
49
49
|
- 📸 **Visual Capture**: Take screenshots and capture complete DOM snapshots with layout information
|
|
50
50
|
- 📊 **Console Monitoring**: Real-time console message capture with filtering and storage
|
|
51
51
|
- 🌐 **Network Monitoring**: Real-time network request/response monitoring with comprehensive filtering
|
|
52
|
+
- 🖱️ **Element Interaction**: Native click, hover, and form filling commands with CSS selector support
|
|
52
53
|
- 🔧 **CLI Interface**: Full command-line interface with argument parsing and routing
|
|
53
54
|
- 🛠️ **IDE Integration**: Install Cursor commands and Claude skills with directory validation and --force option
|
|
54
55
|
- 📦 **Build System**: Complete TypeScript build pipeline with testing framework
|
|
@@ -58,9 +59,6 @@ A command-line tool designed specifically for Large Language Models (LLMs) and A
|
|
|
58
59
|
These features use the `eval` command by design (not as workarounds) - this is the intended approach for LLM-assisted development:
|
|
59
60
|
|
|
60
61
|
- 📄 **Page Navigation**: `eval "window.location.href = 'https://example.com'"`
|
|
61
|
-
- 🖱️ **Element Interaction**: `eval "document.querySelector('#btn').click()"`
|
|
62
|
-
- 📝 **Form Filling**: `eval "document.querySelector('#input').value = 'text'"`
|
|
63
|
-
- 📄 **HTML Content**: `eval "document.documentElement.outerHTML"`
|
|
64
62
|
- 🚀 **Performance Data**: `eval "performance.now()"` or `eval "performance.getEntriesByType('navigation')"`
|
|
65
63
|
- 📱 **User Agent**: `eval "navigator.userAgent"`
|
|
66
64
|
- 🌐 **Network Requests**: `eval "fetch('/api').then(r => r.json())"`
|
|
@@ -93,7 +91,6 @@ This tool is designed for LLM-assisted development. The IDE integrations (`insta
|
|
|
93
91
|
### ⏳ Not Yet Implemented
|
|
94
92
|
|
|
95
93
|
- 📄 **Direct Page Management**: Native commands for creating, closing, listing, and selecting tabs
|
|
96
|
-
- 🖱️ **Direct Element Interaction**: Native click, hover, drag, and form filling commands
|
|
97
94
|
- 🚀 **Performance Analysis**: Native performance profiling and metrics collection
|
|
98
95
|
- 📱 **Device Emulation**: Native device and network condition simulation
|
|
99
96
|
- 📊 **Output Formatting**: Advanced JSON/text formatting with quiet/verbose modes
|
|
@@ -104,6 +101,8 @@ This tool is designed for LLM-assisted development. The IDE integrations (`insta
|
|
|
104
101
|
- ⚡ **JavaScript Execution**: Execute JavaScript code in browser context with full async support
|
|
105
102
|
- 📸 **Visual Capture**: Take screenshots and capture HTML content
|
|
106
103
|
- 📊 **Monitoring**: Monitor console messages and network requests in real-time
|
|
104
|
+
- 🖱️ **Element Interaction**: Native click, hover, and form filling commands with CSS selector support
|
|
105
|
+
- 📝 **Form Automation**: Single field and batch form filling with comprehensive options
|
|
107
106
|
- 🔧 **Flexible Output**: Support for JSON and human-readable text output formats
|
|
108
107
|
- 🚧 **Eval Workarounds**: Many advanced features available through JavaScript execution
|
|
109
108
|
|
|
@@ -179,21 +178,29 @@ chrome-cdp-cli screenshot --filename screenshot.png
|
|
|
179
178
|
# Capture DOM snapshot
|
|
180
179
|
chrome-cdp-cli snapshot --filename dom-snapshot.json
|
|
181
180
|
|
|
182
|
-
#
|
|
183
|
-
chrome-cdp-cli
|
|
181
|
+
# Element interactions
|
|
182
|
+
chrome-cdp-cli click "#submit-button"
|
|
183
|
+
chrome-cdp-cli hover ".menu-item"
|
|
184
|
+
chrome-cdp-cli fill "#email" "user@example.com"
|
|
184
185
|
|
|
185
|
-
#
|
|
186
|
-
chrome-cdp-cli
|
|
186
|
+
# Advanced interactions
|
|
187
|
+
chrome-cdp-cli drag "#draggable" "#dropzone"
|
|
188
|
+
chrome-cdp-cli press_key "Enter"
|
|
189
|
+
chrome-cdp-cli press_key "a" --modifiers Ctrl
|
|
190
|
+
chrome-cdp-cli upload_file "input[type='file']" "./document.pdf"
|
|
191
|
+
chrome-cdp-cli wait_for "#loading" --condition hidden
|
|
192
|
+
chrome-cdp-cli handle_dialog accept
|
|
187
193
|
|
|
188
|
-
#
|
|
189
|
-
chrome-cdp-cli
|
|
194
|
+
# Batch form filling
|
|
195
|
+
chrome-cdp-cli fill_form --fields '[{"selector":"#username","value":"john"},{"selector":"#password","value":"secret"}]'
|
|
190
196
|
|
|
191
|
-
# Monitor network
|
|
197
|
+
# Monitor console and network
|
|
198
|
+
chrome-cdp-cli get_console_message
|
|
192
199
|
chrome-cdp-cli get_network_request
|
|
193
200
|
|
|
194
201
|
# Install IDE integrations
|
|
195
|
-
chrome-cdp-cli
|
|
196
|
-
chrome-cdp-cli
|
|
202
|
+
chrome-cdp-cli install_cursor_command
|
|
203
|
+
chrome-cdp-cli install_claude_skill --skill-type personal
|
|
197
204
|
|
|
198
205
|
# Get help for all commands
|
|
199
206
|
chrome-cdp-cli --help
|
|
@@ -267,6 +274,110 @@ chrome-cdp-cli snapshot --filename dom-snapshot.json
|
|
|
267
274
|
chrome-cdp-cli screenshot --width 1920 --height 1080 --filename custom.png
|
|
268
275
|
```
|
|
269
276
|
|
|
277
|
+
#### Element Interaction
|
|
278
|
+
```bash
|
|
279
|
+
# Click on an element using CSS selector
|
|
280
|
+
chrome-cdp-cli click "#submit-button"
|
|
281
|
+
|
|
282
|
+
# Click with custom timeout
|
|
283
|
+
chrome-cdp-cli click ".slow-loading-button" --timeout 10000
|
|
284
|
+
|
|
285
|
+
# Click without waiting for element (fail immediately if not found)
|
|
286
|
+
chrome-cdp-cli click "#optional-element" --no-wait
|
|
287
|
+
|
|
288
|
+
# Hover over an element
|
|
289
|
+
chrome-cdp-cli hover "#menu-item"
|
|
290
|
+
|
|
291
|
+
# Hover over a dropdown trigger
|
|
292
|
+
chrome-cdp-cli hover ".dropdown-trigger"
|
|
293
|
+
|
|
294
|
+
# Fill a single form field
|
|
295
|
+
chrome-cdp-cli fill "#username" "john@example.com"
|
|
296
|
+
|
|
297
|
+
# Fill a password field
|
|
298
|
+
chrome-cdp-cli fill "input[type='password']" "secret123"
|
|
299
|
+
|
|
300
|
+
# Fill a textarea
|
|
301
|
+
chrome-cdp-cli fill "#message" "Hello, this is a test message"
|
|
302
|
+
|
|
303
|
+
# Select an option in a dropdown (by value or text)
|
|
304
|
+
chrome-cdp-cli fill "#country" "US"
|
|
305
|
+
chrome-cdp-cli fill "#country" "United States"
|
|
306
|
+
|
|
307
|
+
# Fill without clearing existing content
|
|
308
|
+
chrome-cdp-cli fill "#notes" " - Additional note" --no-clear
|
|
309
|
+
|
|
310
|
+
# Fill multiple form fields in batch
|
|
311
|
+
chrome-cdp-cli fill_form --fields '[
|
|
312
|
+
{"selector":"#username","value":"john@example.com"},
|
|
313
|
+
{"selector":"#password","value":"secret123"},
|
|
314
|
+
{"selector":"#country","value":"United States"}
|
|
315
|
+
]'
|
|
316
|
+
|
|
317
|
+
# Fill form from JSON file
|
|
318
|
+
echo '[
|
|
319
|
+
{"selector":"#firstName","value":"John"},
|
|
320
|
+
{"selector":"#lastName","value":"Doe"},
|
|
321
|
+
{"selector":"#email","value":"john.doe@example.com"}
|
|
322
|
+
]' > form-data.json
|
|
323
|
+
chrome-cdp-cli fill_form --fields-file form-data.json
|
|
324
|
+
|
|
325
|
+
# Fill form with custom options
|
|
326
|
+
chrome-cdp-cli fill_form --fields '[
|
|
327
|
+
{"selector":"#notes","value":"Additional information"}
|
|
328
|
+
]' --no-clear --timeout 10000 --stop-on-error
|
|
329
|
+
|
|
330
|
+
# Fill form and continue on errors (default behavior)
|
|
331
|
+
chrome-cdp-cli fill_form --fields '[
|
|
332
|
+
{"selector":"#field1","value":"value1"},
|
|
333
|
+
{"selector":"#nonexistent","value":"value2"},
|
|
334
|
+
{"selector":"#field3","value":"value3"}
|
|
335
|
+
]' --continue-on-error
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
#### Advanced Interactions
|
|
339
|
+
```bash
|
|
340
|
+
# Drag and drop operations
|
|
341
|
+
chrome-cdp-cli drag "#draggable-item" "#drop-zone"
|
|
342
|
+
|
|
343
|
+
# Drag with custom timeout
|
|
344
|
+
chrome-cdp-cli drag ".file-item" ".upload-area" --timeout 10000
|
|
345
|
+
|
|
346
|
+
# Keyboard input simulation
|
|
347
|
+
chrome-cdp-cli press_key "Enter"
|
|
348
|
+
chrome-cdp-cli press_key "Escape"
|
|
349
|
+
chrome-cdp-cli press_key "Tab"
|
|
350
|
+
|
|
351
|
+
# Keyboard input with modifiers
|
|
352
|
+
chrome-cdp-cli press_key "a" --modifiers Ctrl # Ctrl+A (Select All)
|
|
353
|
+
chrome-cdp-cli press_key "s" --modifiers Ctrl # Ctrl+S (Save)
|
|
354
|
+
chrome-cdp-cli press_key "c" --modifiers Ctrl,Shift # Ctrl+Shift+C
|
|
355
|
+
|
|
356
|
+
# Target specific elements for keyboard input
|
|
357
|
+
chrome-cdp-cli press_key "Enter" --selector "#search-input"
|
|
358
|
+
chrome-cdp-cli press_key "ArrowDown" --selector "#dropdown"
|
|
359
|
+
|
|
360
|
+
# File upload to file input elements
|
|
361
|
+
chrome-cdp-cli upload_file "input[type='file']" "./document.pdf"
|
|
362
|
+
chrome-cdp-cli upload_file "#file-input" "/path/to/image.jpg"
|
|
363
|
+
chrome-cdp-cli upload_file ".upload-field" "./test-data.csv"
|
|
364
|
+
|
|
365
|
+
# Wait for elements to appear or meet conditions
|
|
366
|
+
chrome-cdp-cli wait_for "#loading-spinner" # Wait for element to exist
|
|
367
|
+
chrome-cdp-cli wait_for "#modal" --condition visible # Wait for element to be visible
|
|
368
|
+
chrome-cdp-cli wait_for "#loading" --condition hidden # Wait for element to be hidden
|
|
369
|
+
chrome-cdp-cli wait_for "#submit-btn" --condition enabled # Wait for element to be enabled
|
|
370
|
+
chrome-cdp-cli wait_for "#processing-btn" --condition disabled # Wait for element to be disabled
|
|
371
|
+
chrome-cdp-cli wait_for "#slow-element" --timeout 30000 # Custom timeout
|
|
372
|
+
|
|
373
|
+
# Handle browser dialogs (alert, confirm, prompt)
|
|
374
|
+
chrome-cdp-cli handle_dialog accept # Accept dialog
|
|
375
|
+
chrome-cdp-cli handle_dialog dismiss # Dismiss dialog
|
|
376
|
+
chrome-cdp-cli handle_dialog accept --text "John Doe" # Handle prompt with text input
|
|
377
|
+
chrome-cdp-cli handle_dialog accept --text "" # Handle prompt with empty input
|
|
378
|
+
chrome-cdp-cli handle_dialog accept --timeout 10000 # Wait for dialog to appear
|
|
379
|
+
```
|
|
380
|
+
|
|
270
381
|
#### Console Monitoring
|
|
271
382
|
```bash
|
|
272
383
|
# Get latest console message
|
|
@@ -275,7 +386,7 @@ chrome-cdp-cli get_console_message
|
|
|
275
386
|
# List all console messages
|
|
276
387
|
chrome-cdp-cli list_console_messages
|
|
277
388
|
|
|
278
|
-
# Filter console messages
|
|
389
|
+
# Filter console messages by type
|
|
279
390
|
chrome-cdp-cli list_console_messages --filter '{"types":["error","warn"]}'
|
|
280
391
|
```
|
|
281
392
|
|
|
@@ -287,34 +398,34 @@ chrome-cdp-cli get_network_request
|
|
|
287
398
|
# List all network requests
|
|
288
399
|
chrome-cdp-cli list_network_requests
|
|
289
400
|
|
|
290
|
-
# Filter network requests
|
|
401
|
+
# Filter network requests by method
|
|
291
402
|
chrome-cdp-cli list_network_requests --filter '{"methods":["POST"],"statusCodes":[200,201]}'
|
|
292
403
|
```
|
|
293
404
|
|
|
294
405
|
#### IDE Integration
|
|
295
406
|
```bash
|
|
296
407
|
# Install Cursor command (creates .cursor/commands/cdp-cli.md)
|
|
297
|
-
chrome-cdp-cli
|
|
408
|
+
chrome-cdp-cli install_cursor_command
|
|
298
409
|
|
|
299
410
|
# Install Cursor command with --force (bypasses directory validation)
|
|
300
|
-
chrome-cdp-cli
|
|
411
|
+
chrome-cdp-cli install_cursor_command --force
|
|
301
412
|
|
|
302
413
|
# Install Claude skill for project (creates .claude/skills/cdp-cli/SKILL.md)
|
|
303
|
-
chrome-cdp-cli
|
|
414
|
+
chrome-cdp-cli install_claude_skill
|
|
304
415
|
|
|
305
416
|
# Install Claude skill for personal use (creates ~/.claude/skills/cdp-cli/SKILL.md)
|
|
306
|
-
chrome-cdp-cli
|
|
417
|
+
chrome-cdp-cli install_claude_skill --skill-type personal
|
|
307
418
|
|
|
308
419
|
# Install Claude skill with examples and references
|
|
309
|
-
chrome-cdp-cli
|
|
420
|
+
chrome-cdp-cli install_claude_skill --include-examples --include-references
|
|
310
421
|
|
|
311
422
|
# Install with custom directory
|
|
312
|
-
chrome-cdp-cli
|
|
313
|
-
chrome-cdp-cli
|
|
423
|
+
chrome-cdp-cli install_cursor_command --target-directory /custom/path/.cursor/commands
|
|
424
|
+
chrome-cdp-cli install_claude_skill --target-directory /custom/path/.claude/skills
|
|
314
425
|
|
|
315
426
|
# Force install (bypasses directory validation)
|
|
316
|
-
chrome-cdp-cli
|
|
317
|
-
chrome-cdp-cli
|
|
427
|
+
chrome-cdp-cli install_cursor_command --force
|
|
428
|
+
chrome-cdp-cli install_claude_skill --force
|
|
318
429
|
```
|
|
319
430
|
|
|
320
431
|
### 🚧 Available via Eval Workarounds
|
|
@@ -339,14 +450,15 @@ chrome-cdp-cli eval "window.history.forward()"
|
|
|
339
450
|
|
|
340
451
|
#### Element Interaction
|
|
341
452
|
```bash
|
|
342
|
-
#
|
|
343
|
-
chrome-cdp-cli
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
chrome-cdp-cli eval "document.querySelector('#email').value = 'user@example.com'"
|
|
453
|
+
# Native commands (recommended)
|
|
454
|
+
chrome-cdp-cli click "#button"
|
|
455
|
+
chrome-cdp-cli hover ".menu-item"
|
|
456
|
+
chrome-cdp-cli fill "#email" "user@example.com"
|
|
347
457
|
|
|
348
|
-
#
|
|
458
|
+
# Via eval (still available for complex scenarios)
|
|
459
|
+
chrome-cdp-cli eval "document.querySelector('#button').click()"
|
|
349
460
|
chrome-cdp-cli eval "document.querySelector('.menu-item').dispatchEvent(new MouseEvent('mouseover'))"
|
|
461
|
+
chrome-cdp-cli eval "document.querySelector('#email').value = 'user@example.com'"
|
|
350
462
|
|
|
351
463
|
# Check if element exists
|
|
352
464
|
chrome-cdp-cli eval "!!document.querySelector('#element')"
|
|
@@ -360,7 +472,18 @@ chrome-cdp-cli eval "document.querySelector('#element').getAttribute('class')"
|
|
|
360
472
|
|
|
361
473
|
#### Form Handling
|
|
362
474
|
```bash
|
|
363
|
-
#
|
|
475
|
+
# Native batch form filling (recommended)
|
|
476
|
+
chrome-cdp-cli fill_form --fields '[
|
|
477
|
+
{"selector":"#name","value":"John Doe"},
|
|
478
|
+
{"selector":"#email","value":"john@example.com"},
|
|
479
|
+
{"selector":"#phone","value":"123-456-7890"}
|
|
480
|
+
]'
|
|
481
|
+
|
|
482
|
+
# Native single field filling
|
|
483
|
+
chrome-cdp-cli fill "#name" "John Doe"
|
|
484
|
+
chrome-cdp-cli fill "#email" "john@example.com"
|
|
485
|
+
|
|
486
|
+
# Via eval (for complex form operations)
|
|
364
487
|
chrome-cdp-cli eval "
|
|
365
488
|
document.querySelector('#name').value = 'John Doe';
|
|
366
489
|
document.querySelector('#email').value = 'john@example.com';
|
|
@@ -370,7 +493,10 @@ document.querySelector('#phone').value = '123-456-7890';
|
|
|
370
493
|
# Submit form
|
|
371
494
|
chrome-cdp-cli eval "document.querySelector('#myform').submit()"
|
|
372
495
|
|
|
373
|
-
# Select dropdown option
|
|
496
|
+
# Select dropdown option (native)
|
|
497
|
+
chrome-cdp-cli fill "#dropdown" "option1"
|
|
498
|
+
|
|
499
|
+
# Select dropdown option (via eval)
|
|
374
500
|
chrome-cdp-cli eval "document.querySelector('#dropdown').value = 'option1'"
|
|
375
501
|
|
|
376
502
|
# Check checkbox
|
|
@@ -533,7 +659,6 @@ new Promise(resolve => {
|
|
|
533
659
|
### Current Limitations
|
|
534
660
|
|
|
535
661
|
- **No native page management**: Creating, closing, and switching between tabs requires manual implementation
|
|
536
|
-
- **No native element interaction**: Clicking, hovering, and form filling must be done via eval
|
|
537
662
|
- **No performance profiling**: Advanced performance analysis requires manual JavaScript
|
|
538
663
|
- **No device emulation**: Mobile/tablet simulation not yet implemented
|
|
539
664
|
- **Basic output formatting**: Advanced JSON/text formatting options not available
|
|
@@ -544,9 +669,10 @@ new Promise(resolve => {
|
|
|
544
669
|
- `new_page`, `close_page`, `list_pages`, `select_page`
|
|
545
670
|
- Direct CDP Target domain integration
|
|
546
671
|
|
|
547
|
-
2. **Native Element Interaction**
|
|
548
|
-
- `click`, `hover`, `fill`, `
|
|
672
|
+
2. **Native Element Interaction** ✅ **COMPLETED**
|
|
673
|
+
- `click`, `hover`, `fill`, `fill_form` commands
|
|
549
674
|
- CSS selector-based element targeting
|
|
675
|
+
- Comprehensive form filling with batch operations
|
|
550
676
|
|
|
551
677
|
3. **Performance Analysis**
|
|
552
678
|
- `performance_start_trace`, `performance_stop_trace`
|
|
@@ -581,6 +707,191 @@ new Promise(resolve => {
|
|
|
581
707
|
|
|
582
708
|
**This tool is built for LLM-assisted development. The eval-first approach, combined with IDE integrations (Cursor commands & Claude skills), creates a seamless workflow where AI assistants can automate browser tasks as part of your development process.**
|
|
583
709
|
|
|
710
|
+
## Form Filling & Element Interaction
|
|
711
|
+
|
|
712
|
+
The CLI now includes native commands for element interaction and form filling, designed to work seamlessly with both simple and complex automation scenarios.
|
|
713
|
+
|
|
714
|
+
### Single Field Filling
|
|
715
|
+
|
|
716
|
+
```bash
|
|
717
|
+
# Fill a text input
|
|
718
|
+
chrome-cdp-cli fill "#username" "john@example.com"
|
|
719
|
+
|
|
720
|
+
# Fill a password field
|
|
721
|
+
chrome-cdp-cli fill "input[type='password']" "secret123"
|
|
722
|
+
|
|
723
|
+
# Fill a textarea
|
|
724
|
+
chrome-cdp-cli fill "#message" "Hello, this is a test message"
|
|
725
|
+
|
|
726
|
+
# Select dropdown option (by value or text)
|
|
727
|
+
chrome-cdp-cli fill "#country" "US"
|
|
728
|
+
chrome-cdp-cli fill "#country" "United States"
|
|
729
|
+
|
|
730
|
+
# Fill without clearing existing content
|
|
731
|
+
chrome-cdp-cli fill "#notes" " - Additional note" --no-clear
|
|
732
|
+
|
|
733
|
+
# Fill with custom timeout
|
|
734
|
+
chrome-cdp-cli fill ".slow-loading-field" "value" --timeout 10000
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
### Batch Form Filling
|
|
738
|
+
|
|
739
|
+
```bash
|
|
740
|
+
# Fill multiple fields at once
|
|
741
|
+
chrome-cdp-cli fill_form --fields '[
|
|
742
|
+
{"selector":"#firstName","value":"John"},
|
|
743
|
+
{"selector":"#lastName","value":"Doe"},
|
|
744
|
+
{"selector":"#email","value":"john.doe@example.com"},
|
|
745
|
+
{"selector":"#country","value":"United States"}
|
|
746
|
+
]'
|
|
747
|
+
|
|
748
|
+
# Fill form from JSON file
|
|
749
|
+
echo '[
|
|
750
|
+
{"selector":"#username","value":"testuser"},
|
|
751
|
+
{"selector":"#password","value":"testpass"},
|
|
752
|
+
{"selector":"#confirmPassword","value":"testpass"}
|
|
753
|
+
]' > login-form.json
|
|
754
|
+
chrome-cdp-cli fill_form --fields-file login-form.json
|
|
755
|
+
|
|
756
|
+
# Advanced options
|
|
757
|
+
chrome-cdp-cli fill_form --fields '[
|
|
758
|
+
{"selector":"#field1","value":"value1"},
|
|
759
|
+
{"selector":"#field2","value":"value2"}
|
|
760
|
+
]' --no-clear --timeout 15000 --stop-on-error
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
### Element Interaction
|
|
764
|
+
|
|
765
|
+
```bash
|
|
766
|
+
# Click elements
|
|
767
|
+
chrome-cdp-cli click "#submit-button"
|
|
768
|
+
chrome-cdp-cli click ".menu-item" --timeout 5000
|
|
769
|
+
|
|
770
|
+
# Hover over elements
|
|
771
|
+
chrome-cdp-cli hover "#dropdown-trigger"
|
|
772
|
+
chrome-cdp-cli hover ".tooltip-element" --no-wait
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
### Form Filling Options
|
|
776
|
+
|
|
777
|
+
**Single Field Options (`fill` command):**
|
|
778
|
+
- `--wait-for-element` / `--no-wait`: Wait for element to appear (default: true)
|
|
779
|
+
- `--timeout <ms>`: Timeout for waiting (default: 5000ms)
|
|
780
|
+
- `--clear-first` / `--no-clear`: Clear field before filling (default: true)
|
|
781
|
+
|
|
782
|
+
**Batch Form Options (`fill_form` command):**
|
|
783
|
+
- `--fields <json>`: JSON array of field objects
|
|
784
|
+
- `--fields-file <file>`: JSON file containing field array
|
|
785
|
+
- `--wait-for-elements` / `--no-wait`: Wait for all elements (default: true)
|
|
786
|
+
- `--timeout <ms>`: Timeout for each field (default: 5000ms)
|
|
787
|
+
- `--clear-first` / `--no-clear`: Clear all fields before filling (default: true)
|
|
788
|
+
- `--continue-on-error` / `--stop-on-error`: Continue if field fails (default: continue)
|
|
789
|
+
|
|
790
|
+
### Supported Form Elements
|
|
791
|
+
|
|
792
|
+
**Input Types:**
|
|
793
|
+
- Text inputs (`<input type="text">`)
|
|
794
|
+
- Email inputs (`<input type="email">`)
|
|
795
|
+
- Password inputs (`<input type="password">`)
|
|
796
|
+
- Number inputs (`<input type="number">`)
|
|
797
|
+
- Search inputs (`<input type="search">`)
|
|
798
|
+
- URL inputs (`<input type="url">`)
|
|
799
|
+
|
|
800
|
+
**Other Elements:**
|
|
801
|
+
- Textareas (`<textarea>`)
|
|
802
|
+
- Select dropdowns (`<select>`) - matches by value or text content
|
|
803
|
+
|
|
804
|
+
### Error Handling
|
|
805
|
+
|
|
806
|
+
The form filling commands include comprehensive error handling:
|
|
807
|
+
|
|
808
|
+
```bash
|
|
809
|
+
# Continue filling other fields if one fails (default)
|
|
810
|
+
chrome-cdp-cli fill_form --fields '[
|
|
811
|
+
{"selector":"#valid-field","value":"works"},
|
|
812
|
+
{"selector":"#invalid-field","value":"fails"},
|
|
813
|
+
{"selector":"#another-field","value":"also works"}
|
|
814
|
+
]' --continue-on-error
|
|
815
|
+
|
|
816
|
+
# Stop on first error
|
|
817
|
+
chrome-cdp-cli fill_form --fields '[
|
|
818
|
+
{"selector":"#field1","value":"value1"},
|
|
819
|
+
{"selector":"#nonexistent","value":"value2"}
|
|
820
|
+
]' --stop-on-error
|
|
821
|
+
```
|
|
822
|
+
|
|
823
|
+
### Integration with Eval
|
|
824
|
+
|
|
825
|
+
For complex scenarios, combine native commands with eval:
|
|
826
|
+
|
|
827
|
+
```bash
|
|
828
|
+
# Use native commands for standard operations
|
|
829
|
+
chrome-cdp-cli fill "#username" "john@example.com"
|
|
830
|
+
chrome-cdp-cli fill "#password" "secret123"
|
|
831
|
+
|
|
832
|
+
# Use eval for complex validation or custom logic
|
|
833
|
+
chrome-cdp-cli eval "
|
|
834
|
+
// Validate form before submission
|
|
835
|
+
const username = document.querySelector('#username').value;
|
|
836
|
+
const password = document.querySelector('#password').value;
|
|
837
|
+
if (username && password && password.length >= 8) {
|
|
838
|
+
document.querySelector('#submit').click();
|
|
839
|
+
return 'Form submitted successfully';
|
|
840
|
+
} else {
|
|
841
|
+
return 'Validation failed';
|
|
842
|
+
}
|
|
843
|
+
"
|
|
844
|
+
```
|
|
845
|
+
|
|
846
|
+
## Quick Reference
|
|
847
|
+
|
|
848
|
+
### Form Filling Commands
|
|
849
|
+
|
|
850
|
+
```bash
|
|
851
|
+
# Single field filling
|
|
852
|
+
chrome-cdp-cli fill "#username" "john@example.com"
|
|
853
|
+
chrome-cdp-cli fill "#country" "United States" # Works with dropdowns
|
|
854
|
+
|
|
855
|
+
# Batch form filling
|
|
856
|
+
chrome-cdp-cli fill_form --fields '[
|
|
857
|
+
{"selector":"#username","value":"john"},
|
|
858
|
+
{"selector":"#password","value":"secret"}
|
|
859
|
+
]'
|
|
860
|
+
|
|
861
|
+
# From JSON file
|
|
862
|
+
chrome-cdp-cli fill_form --fields-file form-data.json
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
### Element Interaction Commands
|
|
866
|
+
|
|
867
|
+
```bash
|
|
868
|
+
# Click and hover
|
|
869
|
+
chrome-cdp-cli click "#submit-button"
|
|
870
|
+
chrome-cdp-cli hover ".dropdown-trigger"
|
|
871
|
+
|
|
872
|
+
# With options
|
|
873
|
+
chrome-cdp-cli fill "#field" "value" --timeout 10000 --no-clear
|
|
874
|
+
chrome-cdp-cli click "#button" --no-wait
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
### Core Commands
|
|
878
|
+
|
|
879
|
+
```bash
|
|
880
|
+
# JavaScript execution
|
|
881
|
+
chrome-cdp-cli eval "document.title"
|
|
882
|
+
chrome-cdp-cli eval --file script.js
|
|
883
|
+
|
|
884
|
+
# Visual capture
|
|
885
|
+
chrome-cdp-cli screenshot --filename page.png
|
|
886
|
+
chrome-cdp-cli snapshot --filename dom.json
|
|
887
|
+
|
|
888
|
+
# Monitoring
|
|
889
|
+
chrome-cdp-cli get_console_message
|
|
890
|
+
chrome-cdp-cli list_network_requests
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
For detailed documentation, see the [Form Filling Guide](docs/FORM_FILLING.md).
|
|
894
|
+
|
|
584
895
|
## Configuration
|
|
585
896
|
|
|
586
897
|
### Configuration File
|
|
@@ -806,6 +1117,7 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
806
1117
|
## Support
|
|
807
1118
|
|
|
808
1119
|
- 📖 [Documentation](https://github.com/nickxiao42/chrome-devtools-cli/wiki)
|
|
1120
|
+
- 📝 [Form Filling Guide](docs/FORM_FILLING.md)
|
|
809
1121
|
- 🐛 [Issue Tracker](https://github.com/nickxiao42/chrome-devtools-cli/issues)
|
|
810
1122
|
- 💬 [Discussions](https://github.com/nickxiao42/chrome-devtools-cli/discussions)
|
|
811
1123
|
|
|
@@ -23,6 +23,15 @@ class CLIApplication {
|
|
|
23
23
|
this.cli.registerHandler(new handlers_1.ListNetworkRequestsHandler());
|
|
24
24
|
this.cli.registerHandler(new handlers_1.InstallCursorCommandHandler());
|
|
25
25
|
this.cli.registerHandler(new handlers_1.InstallClaudeSkillHandler());
|
|
26
|
+
this.cli.registerHandler(new handlers_1.ClickHandler());
|
|
27
|
+
this.cli.registerHandler(new handlers_1.HoverHandler());
|
|
28
|
+
this.cli.registerHandler(new handlers_1.FillHandler());
|
|
29
|
+
this.cli.registerHandler(new handlers_1.FillFormHandler());
|
|
30
|
+
this.cli.registerHandler(new handlers_1.DragHandler());
|
|
31
|
+
this.cli.registerHandler(new handlers_1.PressKeyHandler());
|
|
32
|
+
this.cli.registerHandler(new handlers_1.UploadFileHandler());
|
|
33
|
+
this.cli.registerHandler(new handlers_1.WaitForHandler());
|
|
34
|
+
this.cli.registerHandler(new handlers_1.HandleDialogHandler());
|
|
26
35
|
}
|
|
27
36
|
async run(argv) {
|
|
28
37
|
try {
|
|
@@ -242,7 +242,13 @@ For more information about a specific command, use:
|
|
|
242
242
|
'eval': 'Execute JavaScript code',
|
|
243
243
|
'click': 'Click element',
|
|
244
244
|
'fill': 'Fill form field',
|
|
245
|
+
'fill_form': 'Fill multiple form fields in batch',
|
|
245
246
|
'hover': 'Hover over element',
|
|
247
|
+
'drag': 'Perform drag and drop operations',
|
|
248
|
+
'press_key': 'Simulate keyboard input with modifiers',
|
|
249
|
+
'upload_file': 'Upload files to file input elements',
|
|
250
|
+
'wait_for': 'Wait for elements to appear or meet conditions',
|
|
251
|
+
'handle_dialog': 'Handle browser dialogs (alert, confirm, prompt)',
|
|
246
252
|
'screenshot': 'Capture page screenshot',
|
|
247
253
|
'snapshot': 'Capture DOM snapshot with structure and styles',
|
|
248
254
|
'console-messages': 'Get console messages',
|