Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:DevExpress Testcafe ChromeProvider

From Leeroopedia
Knowledge Sources
Domains Browser Automation, Chrome DevTools Protocol
Last Updated 2026-02-12 12:00 GMT

Overview

The Chrome browser provider manages the full lifecycle of Chrome browser instances for TestCafe test execution, including launching, resizing, screenshotting, video capture, native automation, and closing.

Description

The Chrome provider is an object literal exported from src/browser/provider/built-in/dedicated/chrome/index.js that extends the dedicatedProviderBase mixin. It implements browser lifecycle methods that TestCafe's browser connection infrastructure calls to open, control, and close Chrome browser instances. The provider supports both standard and Docker-containerized Chrome, headless mode, device emulation, CDP-based native automation, and multi-window management. It delegates low-level CDP communication to a BrowserClient instance and tracks per-browser state in the openedBrowsers map inherited from the base.

Usage

This provider is used internally by TestCafe whenever a user specifies chrome (or a Chrome variant such as chrome:headless) as the target browser. It is not instantiated directly by end users; instead, TestCafe's browser provider pool discovers it as a built-in dedicated provider and invokes its methods through the BrowserProviderPluginHost wrapper.

Code Reference

Source Location

Signature

export default {
    ...dedicatedProviderBase,

    getConfig (name),
    async getCurrentCDPSession (browserId),
    _getBrowserProtocolClient (runtimeInfo),
    async _createRunTimeInfo (hostName, config, disableMultipleWindows),
    _setUserAgentMetaInfoForEmulatingDevice (browserId, config),
    async _setupNativeAutomation ({ browserClient, runtimeInfo, nativeAutomationOptions }),
    async _startChrome (startOptions, pageUrl),
    async openBrowser (browserId, pageUrl, config, additionalOptions),
    async closeBrowser (browserId, closingInfo = {}),
    async resizeWindow (browserId, width, height, currentWidth, currentHeight),
    async maximizeWindowNativeAutomation (browserId),
    async resizeBounds (browserId, width, height, currentWidth, currentHeight),
    async startCapturingVideo (browserId),
    async stopCapturingVideo (browserId),
    async getVideoFrameData (browserId),
    async hasCustomActionForBrowser (browserId),
    async _ensureWindowIsExpanded (browserId, { height, width, availableHeight, availableWidth, outerWidth, outerHeight }),
    async openFileProtocol (browserId, url),
    async dispatchNativeAutomationEvent (browserId, type, options),
    async dispatchNativeAutomationEventSequence (browserId, eventSequence),
    supportNativeAutomation (),
    getNativeAutomation (browserId),
    async getNewWindowIdInNativeAutomation (browserId),
};

Import

import chromeProvider from '../browser/provider/built-in/dedicated/chrome/index.js';

I/O Contract

Key Method: openBrowser

Input Type Description
browserId string Unique identifier assigned by TestCafe for this browser connection
pageUrl string The initial URL (typically the TestCafe proxy URL) the browser navigates to
config object Parsed Chrome configuration (headless, emulation, deviceName, mobile, etc.)
additionalOptions object Extra flags including nativeAutomation (boolean) and disableMultipleWindows (boolean)
Output Type Description
(side effect) void Populates this.openedBrowsers[browserId] with runtimeInfo, browserClient, viewportSize, and windowDescriptors

Key Method: closeBrowser

Input Type Description
browserId string Unique identifier of the browser to close
closingInfo object Optional object; when isRestarting is true, temp profile directory is preserved
Output Type Description
(side effect) void Disposes native automation, closes browser process, removes temp profile, and deletes browserId from openedBrowsers

Key Method: hasCustomActionForBrowser

Output Key Type Description
hasCloseBrowser boolean Always true
hasResizeWindow boolean True when CDP client exists and config has emulation or headless
hasMaximizeWindow boolean True when CDP client exists and config is headless
hasTakeScreenshot boolean True when CDP client exists
hasChromelessScreenshots boolean True when CDP client exists
hasGetVideoFrameData boolean True when CDP client exists
hasCanResizeWindowToDimensions boolean Always false

Usage Examples

// TestCafe uses the Chrome provider internally. Users interact with it
// through the TestCafe runner API:

import createTestCafe from 'testcafe';

const testcafe = await createTestCafe('localhost', 1337, 1338);
const runner   = testcafe.createRunner();

await runner
    .src('tests/example.js')
    .browsers('chrome:headless')    // triggers ChromeProvider.openBrowser()
    .run();

await testcafe.close();             // triggers ChromeProvider.closeBrowser()
// Internal lifecycle sequence executed by TestCafe:
// 1. provider.openBrowser(browserId, proxyUrl, config, additionalOptions)
//    - Creates ChromeRunTimeInfo
//    - Launches Chrome (local or Docker)
//    - Waits for connection ready
//    - Initializes BrowserClient and native automation
// 2. provider.resizeWindow(browserId, w, h, curW, curH)
// 3. provider.takeScreenshot(browserId, path, vpW, vpH, fullPage)  [from base]
// 4. provider.closeBrowser(browserId, closingInfo)

Related Pages

Page Connections

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