Skip to main content

throttle

Overview

Use the throttle command to simulate different types of network connections for the user.

This command allows you to model the behavior of a website or web application under various network bandwidth conditions.

There are also many presets with ready-made network configuration settings. For example:

  • offline | online
  • GPRS
  • Regular2G | Good2G
  • Regular3G | Good3G
  • Regular4G
  • DSL
  • WiFi
warning

The throttle command only works when using the Chrome DevTools Protocol (CDP).

Read more in the section "How to use Chrome DevTools Protocol in testplane".

Also, see the recipe "How to manage network bandwidth".

Usage

await browser.throttle({ offline, latency, downloadThroughput, uploadThroughput });

Command Parameters

NameTypeDescription
offlineBooleanEnable emulation of a loss of connection.
latencyNumberMinimum latency from the sent request to received response headers, in milliseconds.
downloadThroughputNumberMaximum total download throughput (bytes/sec). -1 disables download throttling.
uploadThroughputNumberMaximum total upload throughput (bytes/sec). -1 disables upload throttling.

Usage Examples

it("should throttle the network", async ({ browser }) => {
// use a preset
await browser.throttle("Regular 3G");

// configure the network settings manually
await browser.throttle({
offline: false,
downloadThroughput: (200 * 1024) / 8,
uploadThroughput: (200 * 1024) / 8,
latency: 20,
});
});

References

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.