Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:DevExpress Testcafe CDP Browser Control

From Leeroopedia
Knowledge Sources
Domains Browser_Automation, Chrome_DevTools_Protocol
Last Updated 2026-02-12 12:00 GMT

Overview

Principle governing programmatic browser control through the Chrome DevTools Protocol (CDP) for screenshots, window management, video capture, device emulation, and native automation.

Description

The Chrome DevTools Protocol allows external tools to instrument Chromium-based browsers. TestCafe uses CDP to go beyond what the hammerhead proxy can do: capturing screenshots via Page.captureScreenshot, resizing windows via Emulation.setDeviceMetricsOverride, capturing video frames via Page.startScreencast, managing tabs via Target domain, and intercepting network requests via Fetch.requestPaused. This eliminates the need for external tools like Selenium WebDriver for Chrome-specific operations.

Usage

This principle applies when TestCafe interacts with Chrome/Chromium/Edge browsers. It is the foundation for native automation mode (proxyless) and also powers screenshot/video/resize operations in proxy mode.

Theoretical Basis

CDP follows a domain-based RPC protocol over WebSocket:

# Abstract CDP interaction pattern
connection = connect(host, port)  # WebSocket to browser's debug port

# Domain operations
connection.Page.captureScreenshot(format='png')  # Screenshot
connection.Emulation.setDeviceMetricsOverride(width, height, scale)  # Resize
connection.Page.startScreencast(format='jpeg', everyNthFrame=1)  # Video
connection.Fetch.enable(patterns=[{requestStage: 'Request'}])  # Intercept
connection.Target.createTarget(url)  # New tab

Each browser tab has its own CDP target with a unique session. TestCafe maintains a dictionary of active CDP client connections keyed by window ID, creating new connections as tabs are opened.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment