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.

Principle:Getgauge Taiko Network Emulation

From Leeroopedia

Template:Principle

Overview

Network Emulation is the technique for simulating various network conditions such as slow connections, offline mode, and bandwidth throttling during browser automation with Taiko.

Description

Network emulation artificially constrains network performance to test application behavior under degraded conditions. It uses the CDP Network.emulateNetworkConditions API to control download throughput, upload throughput, latency, and offline state. This allows testing how the application performs when network conditions are less than ideal, which is critical for ensuring good user experience across diverse real-world connectivity scenarios.

The emulation applies to all network traffic from the browser, including:

  • API requests (XHR, fetch)
  • Resource loading (scripts, stylesheets, images)
  • WebSocket connections
  • Media streaming

Key capabilities:

  • Preset network profiles — Built-in configurations for common network types (GPRS, 2G, 3G, 4G, DSL, WiFi, Offline) with realistic throughput and latency values
  • Custom configurations — Specify exact values for download throughput, upload throughput, latency, and offline state
  • Offline simulation — Completely disconnect the browser from the network to test offline functionality and service worker behavior
  • Bandwidth throttling — Limit download and upload speeds to specific values measured in bytes per second

Usage

Network emulation is used in the following testing scenarios:

  • Performance testing — Verify that the application loads within acceptable timeframes on slow connections
  • Offline testing — Test Progressive Web App (PWA) offline functionality and service worker caching
  • Loading state testing — Verify that loading spinners, skeleton screens, and progress indicators display correctly when network is slow
  • Timeout testing — Ensure that the application properly handles request timeouts on high-latency connections
  • Mobile testing — Simulate mobile network conditions (2G, 3G) to test mobile user experience
  • Graceful degradation — Verify that the application degrades gracefully when bandwidth is limited

Theoretical Basis

Network emulation operates at the browser protocol level, applying constraints to all network activity:

emulateNetwork(networkType) called
        │
        ├── String preset (e.g., 'Good3G')
        │       │
        │       ▼
        │   Look up preset configuration:
        │   { offline: false, downloadThroughput: 196608,
        │     uploadThroughput: 96000, latency: 150 }
        │
        └── Custom object
                │
                ▼
            Use provided configuration directly
        │
        ▼
Network.emulateNetworkConditions({
    offline,
    downloadThroughput,    ← bytes per second
    uploadThroughput,      ← bytes per second
    latency                ← milliseconds of added delay
})
        │
        ▼
All subsequent network requests are throttled
according to the specified conditions

Available network presets:

Preset Download (bytes/s) Upload (bytes/s) Latency (ms) Offline
GPRS 6,400 2,560 500 No
Regular2G 31,250 6,400 300 No
Good2G 56,250 18,750 150 No
Regular3G 96,000 31,250 100 No
Good3G 196,608 96,000 150 No
Regular4G 524,288 524,288 170 No
DSL 262,144 131,072 5 No
WiFi 3,932,160 1,966,080 2 No
Offline 0 0 0 Yes

The emulation is applied at the Chrome network stack level, meaning it affects the actual data transfer rate and adds latency to connection establishment. This provides a realistic simulation of network conditions, as opposed to simply delaying responses at the application level.

Custom configurations allow specifying any combination of the four parameters, enabling simulation of unusual or specific network conditions not covered by the presets.

Related Pages

Implemented By

Page Connections

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