throttle
Overview
Deprecated alias of throttleNetwork. Limits network throughput through CDP/Puppeteer; it is not equivalent to emulate("onLine"). Use throttleNetwork for new code.
Usage
await browser.throttle(profile)
Command parameters
Parameters match throttleNetwork. Pass a profile name: offline, online, GPRS, Regular2G, Good2G, Regular3G, Good3G, Regular4G, DSL, WiFi. Names contain no spaces.
Or pass an object with offline (boolean), latency (milliseconds), downloadThroughput and uploadThroughput (bytes per second, -1 disables throughput limits). Returns Promise<void>.
Limitations
Requires a browser with CDP/Puppeteer access. The implementation selects the first Puppeteer page: use one tab and isolation: false for this example, and navigate first.
In Testplane 9.3.2 / WDIO 9.6.2 / Chrome 150, the online profile did not restore connectivity after offline. Set testsPerSession: 1 to prevent limits leaking into the next test. See throttleNetwork.
Example
Set baseUrl to a test HTTP server that returns 200 at the root path. The example uses a new session for each test.
const assert = require("node:assert/strict");
it("throttle: use the deprecated alias in an isolated session", async ({ browser }) => {
await browser.url("/");
await browser.throttle("Good3G");
const status = await browser.execute(
async () => (await fetch("/?throttled", { cache: "no-store" })).status,
);
assert.equal(status, 200);
});
Related commands
References
This page draws on the original WebdriverIO article.