What Playwright Provides
Playwright offers the most comprehensive browser automation features:- Full JavaScript Rendering - Execute and wait for JavaScript to complete before capturing content
- High-Quality Screenshots - Capture full-page screenshots with configurable quality and format (PNG/JPEG)
- Browser Steps Support - Automate interactions like clicking buttons, filling forms, and logging in
- Visual Selector - Point-and-click element selection for precise monitoring
- XPath Element Data - Extract structured data from page elements
- Advanced Screenshot Stitching - Automatically stitch large pages up to 16,000px height
- Network Control - Access response headers, status codes, and network events
- Proxy Support - Full proxy configuration including authentication
Docker Configuration
To enable Playwright, you need to run a browser service alongside changedetection.io. The recommended approach uses sockpuppetbrowser (a Chrome wrapper optimized for Playwright).Using docker-compose.yml
Uncomment the browser service in yourdocker-compose.yml:
Environment Variables
Required Configuration
PLAYWRIGHT_DRIVER_URL - WebSocket URL to connect to the browser serviceOptional Configuration
PLAYWRIGHT_BROWSER_TYPE - Browser engine to use (default:chromium)
allow)
Proxy Configuration
Playwright supports dedicated proxy settings with theplaywright_proxy_ prefix:
When to Use Playwright
Choose Playwright over the simple HTTP fetcher when:JavaScript-Heavy Websites
- Content is loaded dynamically via AJAX or React/Vue/Angular frameworks
- Prices, stock status, or data appear after page load
- Content requires scrolling or user interaction to appear
Single Page Applications (SPAs)
- Sites that don’t use traditional page navigation
- Modern web apps that update content without refreshing
Authentication Required
- Logging into websites before monitoring protected content
- Using Browser Steps to automate login flows
- Maintaining session state across checks
Visual Monitoring
- Tracking layout changes or visual elements
- Monitoring images, charts, or dynamically rendered graphics
- Using screenshots for visual comparison
Anti-Bot Protection
- Sites using Cloudflare or similar protection
- Pages that block simple HTTP requests
- Sites checking for browser fingerprints
JavaScript Rendering
Playwright executes all JavaScript on the page and waits for content to stabilize before extracting data.Custom JavaScript Execution
You can run custom JavaScript code before content extraction:Render Delays
Playwright automatically waits for:- Page navigation to complete
- DOM content to be loaded
- Network requests to settle
- Additional delay configured via
WEBDRIVER_DELAY_BEFORE_CONTENT_READY
Screenshots and Visual Comparison
Screenshot Formats
JPEG (recommended for most uses)- Smaller file size
- Configurable quality (1-100)
- Faster processing
- Good for content monitoring
- Lossless quality
- Larger file size
- Better for visual comparison
- Preserves transparency
Full-Page Screenshots
Playwright captures the entire page automatically:- Single Viewport - For pages smaller than viewport height, captures in one shot
- Stitched Pages - For tall pages, captures in chunks and stitches seamlessly
- Memory Optimized - Uses subprocess isolation to prevent memory leaks
- Height Limit - Respects
SCREENSHOT_MAX_TOTAL_HEIGHTto prevent excessive memory use
Screenshot Stitching Process
Visual Selector Integration
With Playwright enabled, the Visual Selector tool becomes available:- Click elements on the screenshot to select them
- Generate XPath automatically
- Preview extracted content in real-time
- Refine selections with multiple elements
Performance Considerations
Resource Usage
Memory- Browser processes: ~200-500MB per concurrent watch
- Screenshots: ~5-50MB depending on page size and quality
- Stitching subprocess: temporary memory spike, then released
- JavaScript execution and rendering
- Screenshot encoding (JPEG/PNG)
- Image stitching for large pages
- WebSocket connection to browser service
- Screenshots transferred as base64 (use lower quality to reduce overhead)
- All page resources (images, CSS, JS) are fetched
Optimization Tips
- Lower Screenshot Quality - Set
SCREENSHOT_QUALITY=40for smaller transfers - Limit Screenshot Height - Reduce
SCREENSHOT_MAX_HEIGHTif not needed - Block Service Workers - Set
PLAYWRIGHT_SERVICE_WORKERS=blockfor media sites - Concurrent Processes - Adjust
MAX_CONCURRENT_CHROME_PROCESSESbased on RAM - Use Viewport Sizing - Configure smaller viewport in sockpuppetbrowser for faster renders
Speed Comparison
| Method | Speed | JavaScript | Screenshots | Browser Steps |
|---|---|---|---|---|
| HTTP Requests | Fast (100ms) | No | No | No |
| Playwright | Medium (2-5s) | Yes | Yes | Yes |
| Selenium WebDriver | Slow (5-10s) | Yes | Limited | No |
Browser Steps Integration
Playwright is the only fetcher that supports Browser Steps automation:Supported Actions
- Click elements
- Fill text fields
- Select dropdowns
- Wait for elements
- Execute custom JavaScript
- Take screenshots at each step
- Navigate between pages
Example: Login Flow
Troubleshooting
Connection Issues
If changedetection.io can’t connect to Playwright:Memory Issues
Slow Performance
Screenshot Quality Issues
Comparison with Other Fetchers
vs. HTTP Requests Fetcher
Playwright Advantages:- Executes JavaScript
- Gets real rendered content
- Handles modern web apps
- Takes screenshots
- Supports automation
- Much faster (100x)
- Lower resource usage
- Works for static content
- No browser service needed
vs. Selenium WebDriver
Playwright Advantages:- Better screenshot support (full page)
- Reports HTTP status codes
- More reliable
- Supports Browser Steps
- Better error handling
- Active development
- Deprecated in changedetection.io
- No Browser Steps support
- Limited screenshot quality
- No status code reporting
- Legacy technology
vs. Puppeteer Direct
Playwright Advantages:- More stable
- Better maintained
- Cross-browser support
- Better error messages
- Slightly faster startup
- Can be enabled with
FAST_PUPPETEER_CHROME_FETCHER=True - Same underlying browser (Chrome)
Advanced Configuration
Custom Browser Connection
Connect to external browser services:Viewport Sizing
Configure in sockpuppetbrowser startup:Multiple Browser Types
Best Practices
- Start with HTTP Requests - Only use Playwright when JavaScript is needed
- Use Visual Selector - Easier than writing XPath manually
- Optimize Screenshots - Balance quality vs. performance for your needs
- Monitor Resource Usage - Watch memory and CPU when scaling
- Test Browser Steps - Verify automation works before relying on it
- Set Appropriate Delays - Too short misses content, too long wastes time
- Use Proxies Wisely - Rotate IPs for high-volume monitoring
- Regular Cleanup - Restart browser service periodically to free memory
Related Documentation
- Browser Steps - Automate interactions before monitoring
- Visual Selector - Point-and-click element selection
- Proxy Configuration - Using proxies with Playwright
- Selenium WebDriver - Legacy browser option
- Chrome Extension - Add watches from your browser