Principle:DevExpress Testcafe Native Automation Request Interception
| Knowledge Sources | |
|---|---|
| Domains | Request_Interception, Native_Automation, Chrome_DevTools_Protocol |
| Last Updated | 2026-02-12 12:00 GMT |
Overview
Principle governing the interception, modification, and injection of HTTP requests and responses through CDP's Fetch domain, replacing the traditional proxy-based approach.
Description
In native automation mode, TestCafe bypasses the hammerhead proxy entirely and uses CDP's Fetch domain to intercept all network requests at the browser level. This enables the same capabilities as the proxy (script injection, request mocking, request logging, authentication handling) but with lower latency and better compatibility with modern web features like service workers and WebSockets. The pipeline classifies requests (internal, service, regular), invokes request hooks, handles mock responses, injects TestCafe client scripts into HTML responses, manages iframe context tracking, and handles special cases like SSL certificate errors and HTTP basic auth.
Usage
This principle applies when running TestCafe in native automation mode (proxyless). It is the default mode for Chromium-based browsers and is the future direction for TestCafe's architecture.
Theoretical Basis
The request pipeline follows an interceptor pattern at the CDP level:
# Abstract request interception pipeline
on_request_paused(event):
if is_special_request(event):
handle_special(event) # Internal, service, favicon
return
context = create_context(event)
# Request phase
invoke_request_hooks(context)
if has_mock_response(context):
fulfill_with_mock(event, context)
return
continue_request(event) # Let browser fetch normally
on_response_paused(event):
response = get_response(event)
if is_html_page(response):
inject_scripts(response) # Add TestCafe client code
inject_storage_restore(response)
invoke_response_hooks(context)
continue_response(event, modified_response)