playwright-mcp/test-smart-recording.js
Ryan Malloy 224f040645 feat: smart video recording with viewport matching and enhanced tool descriptions
Video Recording Enhancements:
- Add intelligent recording modes: smart, continuous, action-only, segment
- Implement automatic viewport matching to eliminate gray borders in videos
- Add pause/resume functionality with manual and automatic control
- Default to 1280x720 HD recording with auto-viewport matching
- Enhanced browser_start_recording with autoSetViewport parameter

Smart Recording System:
- Smart mode: Auto-pause during waits, resume during actions (perfect for demos)
- Action-only mode: Only record during browser interactions
- Segment mode: Create separate video files for each action sequence
- Continuous mode: Traditional behavior with optional manual pause/resume

Tool Enhancements:
- Comprehensive descriptions for all video recording tools
- Professional context and use case guidance
- Integration with browser_wait_for for recordDuringWait parameter
- Action-aware recording in navigation and interaction tools
- Enhanced browser_recording_status with mode and viewport info

Documentation & Testing:
- Complete best practices guide for video recording workflows
- Viewport matching diagnostic and setup scripts
- Recommended video sizes and quality settings
- Gray border problem solution with automatic viewport matching

Solves the gray border issue by ensuring browser viewport matches video
recording dimensions, creating professional full-frame demo videos.
2025-09-06 10:46:23 -06:00

129 lines
5.8 KiB
JavaScript
Executable File

#!/usr/bin/env node
/**
* Smart Video Recording Test Script
*
* Tests the new smart recording features:
* - Recording modes (continuous, smart, action-only, segment)
* - Auto-pause/resume during waits
* - Manual pause/resume controls
* - Action-aware recording
*/
console.log('🎬 Smart Video Recording Test');
console.log('============================\n');
const testWorkflow = `
# Smart Recording Test Workflow
## Test 1: Smart Mode (Default)
1. browser_start_recording() # Should start in smart mode
2. browser_recording_status() # Check mode and status
3. browser_navigate({url: "https://example.com"}) # Should auto-resume for action
4. browser_wait_for({time: 3}) # Should auto-pause during wait
5. browser_recording_status() # Should show paused
6. browser_click(...some element...) # Should auto-resume for action
7. browser_wait_for({time: 2, recordDuringWait: true}) # Should keep recording
8. browser_stop_recording() # Finalize and show video paths
## Test 2: Recording Mode Changes
1. browser_set_recording_mode({mode: "continuous"}) # Switch to continuous
2. browser_start_recording() # Start continuous recording
3. browser_navigate({url: "https://httpbin.org"}) # Should not pause
4. browser_wait_for({time: 3}) # Should not pause
5. browser_set_recording_mode({mode: "segment"}) # Switch to segment mode
6. browser_click(...some element...) # Should create new segment
7. browser_stop_recording() # Show all segments
## Test 3: Manual Controls
1. browser_start_recording() # Start recording
2. browser_navigate({url: "https://example.com"}) # Action
3. browser_pause_recording() # Manual pause
4. browser_wait_for({time: 5}) # Long wait (no recording)
5. browser_resume_recording() # Manual resume
6. browser_click(...some element...) # Action should record
7. browser_stop_recording() # Finalize
## Test 4: Path Resolution
1. browser_reveal_artifact_paths() # Show where videos are stored
2. browser_start_recording() # Start recording
3. browser_recording_status() # Show current paths and status
4. Perform some actions...
5. browser_stop_recording() # Get actual video file paths
## Expected Results:
✅ Smart mode auto-pauses during waits, resumes during actions
✅ Continuous mode never pauses
✅ Segment mode creates separate files per action sequence
✅ Manual pause/resume works independently of mode
✅ recordDuringWait parameter overrides smart mode behavior
✅ Status tool shows current mode and pause state
✅ Actual video files are created at reported paths
`;
console.log(testWorkflow);
console.log('🎯 Key Features to Test:');
console.log('========================');
console.log('1. 📊 browser_set_recording_mode - Choose recording behavior');
console.log('2. ⏸️ browser_pause_recording - Manual pause control');
console.log('3. ▶️ browser_resume_recording - Manual resume control');
console.log('4. 🧠 Smart wait handling - browser_wait_for with recordDuringWait');
console.log('5. 📈 Enhanced status - browser_recording_status shows mode/state');
console.log('6. 🗂️ Path discovery - browser_reveal_artifact_paths shows locations');
console.log('7. 🎞️ Segment mode - Creates separate files per action sequence');
console.log('');
console.log('💡 LLM-Friendly Usage Patterns:');
console.log('===============================');
console.log('');
console.log('🎬 For Clean Demo Videos (Recommended):');
console.log('```');
console.log('browser_set_recording_mode({mode: "smart"}) // Auto-pause during waits');
console.log('browser_start_recording()');
console.log('// Perform demo actions - recording auto-manages pausing');
console.log('browser_navigate(...), browser_click(...), etc.');
console.log('browser_wait_for({time: 5}) // Auto-pauses here');
console.log('browser_stop_recording() // Clean video with minimal dead time');
console.log('```');
console.log('');
console.log('🎞️ For Action Sequences:');
console.log('```');
console.log('browser_set_recording_mode({mode: "segment"}) // Separate file per action');
console.log('browser_start_recording()');
console.log('browser_navigate(...) // Creates segment-1.webm');
console.log('browser_click(...) // Creates segment-2.webm');
console.log('browser_type(...) // Creates segment-3.webm');
console.log('browser_stop_recording() // Returns array of segment paths');
console.log('```');
console.log('');
console.log('⚡ For Minimal Recording:');
console.log('```');
console.log('browser_set_recording_mode({mode: "action-only"}) // Only record interactions');
console.log('browser_start_recording()');
console.log('// Automatically pauses between actions, resumes during interactions');
console.log('browser_stop_recording()');
console.log('```');
console.log('');
console.log('📹 For Traditional Behavior:');
console.log('```');
console.log('browser_set_recording_mode({mode: "continuous"}) // Never auto-pause');
console.log('browser_start_recording()');
console.log('// Records everything including waits (original behavior)');
console.log('browser_stop_recording()');
console.log('```');
console.log('');
console.log('🔧 Manual Control When Needed:');
console.log('```');
console.log('browser_start_recording()');
console.log('browser_navigate(...)');
console.log('browser_pause_recording() // Manual pause before long wait');
console.log('// ... long processing or thinking time ...');
console.log('browser_resume_recording() // Manual resume before next action');
console.log('browser_click(...)');
console.log('browser_stop_recording()');
console.log('```');