Advanced Hybrid Automations
Advanced Configurations
Stream Quality and Performance
Control bandwidth usage and visual quality based on your needs:
- Puppeteer
- Playwright
const { liveURL } = await cdp.send('Browserless.liveURL', {
quality: 50, // 1-100, lower = less bandwidth
type: 'jpeg', // 'jpeg' or 'png'
timeout: 60000, // Session timeout in milliseconds
});
const { liveURL } = await cdpSession.send('Browserless.liveURL', {
quality: 50, // 1-100, lower = less bandwidth
type: 'jpeg', // 'jpeg' or 'png'
timeout: 60000, // Session timeout in milliseconds
});
Viewport and Interaction Control
- Puppeteer
- Playwright
const { liveURL } = await cdp.send('Browserless.liveURL', {
resizable: false, // Maintain fixed viewport
interactable: true, // Allow user interaction
showBrowserInterface: false, // Show/hide browser tabs and UI
});
const { liveURL } = await cdpSession.send('Browserless.liveURL', {
resizable: false, // Maintain fixed viewport
interactable: true, // Allow user interaction
showBrowserInterface: false, // Show/hide browser tabs and UI
});
Event Handling
Listen for important events during the session:
- Puppeteer
- Playwright
// Detect CAPTCHA challenges
cdp.on('Browserless.captchaFound', () => {
console.log('CAPTCHA detected - user intervention needed');
});
// Session completion
cdp.on('Browserless.liveComplete', () => {
console.log('User closed the session');
});
// Detect CAPTCHA challenges
cdpSession.on('Browserless.captchaFound', () => {
console.log('CAPTCHA detected - user intervention needed');
});
// Session completion
cdpSession.on('Browserless.liveComplete', () => {
console.log('User closed the session');
});
Programmatic Session Control
Manage sessions programmatically for precise control:
- Puppeteer
- Playwright
// Get both URL and ID for programmatic control
const { liveURL, liveURLId } = await cdp.send('Browserless.liveURL');
// Wait for specific condition
await page.waitForSelector('.success-indicator');
// Programmatically close the session
await cdp.send('Browserless.closeLiveURL', { liveURLId });
// Get both URL and ID for programmatic control
const { liveURL, liveURLId } = await cdpSession.send('Browserless.liveURL');
// Wait for specific condition
await page.waitForSelector('.success-indicator');
// Programmatically close the session
await cdpSession.send('Browserless.closeLiveURL', { liveURLId });
Read-Only Sessions
Create view-only sessions for monitoring or demonstrations:
- Puppeteer
- Playwright
const { liveURL } = await cdp.send('Browserless.liveURL', {
interactable: false, // Users can only view, not interact
quality: 80,
});
const { liveURL } = await cdpSession.send('Browserless.liveURL', {
interactable: false, // Users can only view, not interact
quality: 80,
});
Best Practices
Security Considerations
- LiveURLs contain no API tokens - safe to share externally
- Set appropriate timeouts to limit session duration
- Use
interactable: false
for view-only scenarios
Performance Optimization
- Use
quality: 30-50
for mobile devices or slow connections - Choose
type: 'jpeg'
for better compression - Set reasonable timeouts to prevent resource waste
Error Handling
- Always implement proper cleanup in try/finally blocks
- Listen for
Browserless.liveComplete
events to detect early termination - Handle network interruptions gracefully