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 NativeAutomation RequestPipeline

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

Overview

Concrete tool for intercepting and processing all HTTP requests and responses through the CDP Fetch domain in native automation mode.

Description

The NativeAutomationRequestPipeline class extends NativeAutomationApiBase and implements the core request interception pipeline for native automation mode. It enables Fetch.requestPaused interception for all requests and responses, routing special requests (internal, service, favicon) through dedicated handlers. For regular requests, it initializes context info, invokes request hooks, handles mock responses, processes HTML page content with resource injection (scripts, styles, storage restoration), manages iframe contexts via frame tree tracking, handles redirects, SSL certificate errors, DNS failures, and HTTP basic auth. It uses safe API wrappers to gracefully handle CDP connection reset errors.

Usage

This pipeline is activated when TestCafe runs in native automation mode (proxyless). It replaces the traditional hammerhead proxy-based request interception, communicating directly with the browser via CDP.

Code Reference

Source Location

Signature

export default class NativeAutomationRequestPipeline extends NativeAutomationApiBase {
    private _contextInfo: NativeAutomationRequestContextInfo;
    private _resourceInjector: ResourceInjector;
    private _specialServiceRoutes: SpecialServiceRoutes;
    private _requestHookEventProvider: NativeAutomationRequestHookEventProvider;
    private _stopped: boolean;
    private _currentFrameTree: FrameTree | null;

    public constructor (
        browserId: string,
        client: ProtocolApi,
        options: NativeAutomationInitOptions
    );

    public async init (): Promise<void>;
    public stop (): void;
    public async dispose (): Promise<void>;
    public setMockingOptions (responseEventId: string, mock: any): void;
}

Import

import NativeAutomationRequestPipeline from './native-automation/request-pipeline';

I/O Contract

Inputs

Name Type Required Description
browserId string Yes The browser connection ID
client ProtocolApi Yes CDP protocol API client
options NativeAutomationInitOptions Yes Configuration including service routes, test run bridge, request hooks

Outputs

Name Type Description
Request interception CDP events Intercepts and modifies all network traffic via CDP Fetch domain
Resource injection HTML modification Injects TestCafe client scripts into HTML responses
Request hooks Hook events Triggers registered request hooks (RequestLogger, RequestMock)

Usage Examples

// Internal usage within native automation module
import NativeAutomationRequestPipeline from './request-pipeline';

// 1. Create pipeline with CDP client
const pipeline = new NativeAutomationRequestPipeline(
    browserId,
    cdpClient,
    {
        specialServiceRoutes,
        testRunBridge,
        requestHookClassInstances: [requestLogger, requestMock],
        // ...other options
    }
);

// 2. Initialize CDP interception
await pipeline.init();

// 3. Pipeline automatically intercepts all requests
// It injects scripts, processes mocks, and handles auth

// 4. Stop and dispose when done
pipeline.stop();
await pipeline.dispose();

Related Pages

Page Connections

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