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:Getgauge Taiko NetworkConditions

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

Overview

The NetworkConditions module defines a static dictionary of predefined network throttling profiles that simulate various real-world connection speeds, from GPRS to WiFi and Offline mode.

Description

NetworkConditions is a pure data module that exports an object mapping human-readable network condition names to their corresponding throttling parameters. Each profile specifies four properties: offline (boolean indicating whether the network is fully disconnected), downloadThroughput (maximum download speed in bytes per second), uploadThroughput (maximum upload speed in bytes per second), and latency (additional round-trip delay in milliseconds).

The throughput values are expressed as computed expressions in the source code (e.g., (50 * 1024) / 8 for GPRS download) that convert from kilobits-per-second to bytes-per-second. This conversion follows the formula: (kbps * 1024) / 8, where 1024 converts kilobits to bits and division by 8 converts bits to bytes. For higher-speed profiles (Good3G and above), the source values are in megabits-per-second using (mbps * 1024 * 1024) / 8.

The nine profiles cover the full spectrum of network conditions:

  • Cellular: GPRS, Regular2G, Good2G, Regular3G, Good3G, Regular4G
  • Wired/Wireless: DSL, WiFi
  • Disconnected: Offline

These profiles are consumed by the NetworkHandler when the user invokes Taiko's setNetworkConditions API, which applies them via the CDP Network.emulateNetworkConditions command.

Usage

Use NetworkConditions to select a predefined throttling profile when testing application behavior under constrained network conditions. Pass a profile name (e.g., "Good3G") to Taiko's network emulation API. The profiles are designed to match Chrome DevTools' built-in network presets.

Code Reference

Source Location

Signature

module.exports = {
  GPRS:       { offline, downloadThroughput, uploadThroughput, latency },
  Regular2G:  { offline, downloadThroughput, uploadThroughput, latency },
  Good2G:     { offline, downloadThroughput, uploadThroughput, latency },
  Regular3G:  { offline, downloadThroughput, uploadThroughput, latency },
  Good3G:     { offline, downloadThroughput, uploadThroughput, latency },
  Regular4G:  { offline, downloadThroughput, uploadThroughput, latency },
  DSL:        { offline, downloadThroughput, uploadThroughput, latency },
  WiFi:       { offline, downloadThroughput, uploadThroughput, latency },
  Offline:    { offline, downloadThroughput, uploadThroughput, latency },
}

Import

const networkConditions = require("./data/networkConditions");

I/O Contract

Profile Schema

Each profile is an object with the following properties:

Property Type Description
offline boolean When true, simulates a completely disconnected network.
downloadThroughput number Maximum download speed in bytes per second.
uploadThroughput number Maximum upload speed in bytes per second.
latency number Additional round-trip latency in milliseconds.

Profile Values

Profile Offline Download (bytes/s) Upload (bytes/s) Latency (ms) Approx Speed
GPRS false 6,400 2,560 500 50 kbps / 20 kbps
Regular2G false 32,000 6,400 300 250 kbps / 50 kbps
Good2G false 57,600 19,200 150 450 kbps / 150 kbps
Regular3G false 96,000 32,000 100 750 kbps / 250 kbps
Good3G false 196,608 96,000 40 1.5 Mbps / 750 kbps
Regular4G false 524,288 393,216 20 4 Mbps / 3 Mbps
DSL false 262,144 131,072 5 2 Mbps / 1 Mbps
WiFi false 3,932,160 1,966,080 2 30 Mbps / 15 Mbps
Offline true 0 0 0 No connectivity

Algorithm

This is a pure data module with no algorithmic logic. The throughput values are computed at module load time using constant expressions:

// Pattern for kbps values (GPRS through Regular3G, Good3G upload):
downloadThroughput: (kbps * 1024) / 8

// Pattern for Mbps values (Good3G download through WiFi):
downloadThroughput: (mbps * 1024 * 1024) / 8

The conversion chain is:

  1. Start with the nominal speed in kilobits or megabits per second
  2. Multiply by 1024 (or 1024*1024 for Mbps) to convert to bits per second
  3. Divide by 8 to convert bits to bytes per second

The Offline profile uses all-zero throughput values with offline: true, which tells the CDP Network domain to reject all network requests.

Usage Examples

// Retrieve a specific network condition profile
const networkConditions = require("./data/networkConditions");
const good3g = networkConditions["Good3G"];
// good3g => {
//   offline: false,
//   downloadThroughput: 196608,
//   uploadThroughput: 96000,
//   latency: 40
// }

// List all available condition names
const profileNames = Object.keys(networkConditions);
// => ["GPRS", "Regular2G", "Good2G", "Regular3G", "Good3G",
//     "Regular4G", "DSL", "WiFi", "Offline"]

// Used by Taiko API (end-user perspective):
// await setNetworkConditions("Good3G");
// This internally looks up networkConditions["Good3G"] and passes
// the values to Network.emulateNetworkConditions CDP command.

Related Pages

Page Connections

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