Handle Pages with Videos
Overview
Web pages often contain video content that plays dynamically, changing frame by frame. In visual regression testing, this dynamic content can cause false positives because each frame of the video appears different, even when the actual page design and layout remain unchanged.
SmartUI automatically handles video content by capturing the first frame of videos during visual comparison, ensuring that dynamic video playback doesn't interfere with your visual regression tests.
How SmartUI Handles Videos
Automatic First Frame Capture
When SmartUI encounters a video element on a page, it automatically:
- Captures the First Frame: Extracts the initial frame of the video as a static image
- Treats as Static Content: Uses this first frame as a stable reference point for comparison
- Ignores Playback Changes: Subsequent frames and playback changes are not considered in the comparison
This approach ensures that:
- Video content doesn't cause false positives
- The page layout and design are accurately compared
- Test results focus on actual UI changes, not video playback
Process Flow
Page Load → Video Detection → First Frame Extraction → Static Image Comparison → Results
Benefits
Accurate Visual Testing
By capturing only the first frame, SmartUI ensures that visual regression tests focus on static layout and design elements rather than dynamic video content. This provides more reliable and meaningful test results.
Efficient Workflow
No manual configuration or custom scripts are required. SmartUI automatically handles video content, reducing the need for:
- Custom video handling code
- Manual video pausing scripts
- Complex workarounds for dynamic content
Improved Test Reliability
False positives caused by video playback variations are eliminated, resulting in:
- More stable test results
- Reduced manual review time
- Higher confidence in test outcomes
Use Cases
Use Case 1: Product Demo Pages
Scenario: Product pages feature embedded demo videos that auto-play or change frames.
Solution: SmartUI automatically captures the first frame, allowing you to focus on comparing the page layout, product information, and static elements without video interference.
Use Case 2: Marketing Landing Pages
Scenario: Landing pages include hero videos or background videos that play continuously.
Solution: The first frame is captured, ensuring consistent comparison of the overall page design, call-to-action buttons, and static content.
Use Case 3: Video Gallery Pages
Scenario: Pages with multiple video thumbnails or video galleries where thumbnails may change.
Solution: SmartUI captures the initial state of all videos, providing stable baseline for comparing gallery layouts and page structure.
Use Case 4: Educational Content Pages
Scenario: Educational platforms with embedded tutorial videos or course previews.
Solution: First frame capture ensures that course layouts, navigation, and static content are accurately compared while ignoring video playback variations.
Configuration
SmartUI handles videos automatically with no additional configuration required. However, you can enhance video handling by:
Using waitForTimeout
If videos take time to load, you can add a wait timeout to ensure the first frame is captured correctly:
{
"web": {
"browsers": ["chrome"],
"viewports": [[1920, 1080]]
},
"waitForTimeout": 3000
}
Combining with Other Features
You can combine video handling with other SmartUI features:
Example: Ignoring video controls while keeping the first frame
let options = {
ignoreDOM: {
cssSelector: [".video-controls", ".play-button"]
}
};
await smartuiSnapshot(driver, 'Video Page', options);
Limitations and Considerations
Supported Video Formats
SmartUI handles standard HTML5 video elements:
<video>tags with standard formats (MP4, WebM, OGG)- Embedded videos via iframe (YouTube, Vimeo, etc.)
- Video elements with autoplay attributes
First Frame Consistency
- The first frame captured may vary slightly if videos have different loading times
- Videos with preload="none" may not have a first frame immediately available
- Consider using
waitForTimeoutfor videos that load slowly
Video Overlays
- Video controls, overlays, and UI elements are included in the snapshot
- Use
ignoreDOMif you need to exclude video controls from comparison - Overlays that appear after the first frame are not captured
Autoplay Videos
- Autoplay videos are handled the same way as regular videos
- The first frame is captured regardless of autoplay status
- Videos that start playing immediately still have their first frame captured
Best Practices
- Allow Video Loading
- Test Video Pages
- Combine with Other Features
- Document Video Content
- Review First Frames
Allow Video Loading
Use appropriate waitForTimeout values to ensure videos are loaded before snapshots.
Test Video Pages
Verify that video pages work correctly with SmartUI before running full test suites.
Combine with Other Features
Use ignoreDOM to exclude video controls if needed.
Document Video Content
Note which pages contain videos for better test planning.
Review First Frames
Occasionally review captured first frames to ensure they represent the intended baseline.
Troubleshooting
- Videos Not Captured Correctly
- False Positives from Video Areas
- Embedded Videos (YouTube, Vimeo)
Issue: Videos Not Captured Correctly
Symptoms: Video areas appear blank or incorrect in snapshots
Solutions:
- Increase
waitForTimeoutto allow videos to load - Check if videos are loaded via JavaScript (may need explicit waits)
- Verify video elements are present in the DOM before snapshot
// Wait for video to load
await driver.wait(until.elementLocated(By.tagName('video')), 10000);
await driver.sleep(2000); // Additional wait for first frame
await smartuiSnapshot(driver, 'Video Page');
Issue: False Positives from Video Areas
Symptoms: Video areas show differences even when page design is unchanged
Solutions:
- Verify SmartUI is capturing first frames (check baseline images)
- Use
ignoreDOMto exclude video elements if first frame capture isn't sufficient - Consider using layout comparison mode for pages with many videos
Issue: Embedded Videos (YouTube, Vimeo)
Symptoms: Embedded videos via iframe may not be captured correctly
Solutions:
- Embedded videos in iframes are handled automatically
- If issues persist, consider using
ignoreDOMfor iframe areas - Check if iframe content is accessible (CORS policies may affect this)
Additional Resources
- Comprehensive Troubleshooting Guide - Solutions for video-related issues
- Handling Dynamic Data - Handle other dynamic content types
- Handling Lazy Loading - Handle lazy-loaded content
- SmartUI Configuration Options - Configure
waitForTimeoutand other options - Smart Ignore Feature - Automatically ignore layout shifts
- Project Settings - Configure comparison settings and thresholds
