How to Manage Network Bandwidth
Overview
warning
This recipe only works when using Chrome DevTools Protocol (CDP).
Read details in the section “How to use CDP in Testplane”.
A large number of users access services from mobile devices where internet speed can be quite slow or may even drop out intermittently. In webdriverio, we can limit network bandwidth using the throttle method, thereby testing the website's behavior under various network conditions.
Besides custom settings, the throttle method supports the following ready-made presets:
- offline | online
- GPRS
- Regular2G | Good2G
- Regular3G | Good3G
- Regular4G
- DSL
- WiFi
Example 1: Emulating a 2G Connection
Let's emulate a 2G connection and open yandex.ru in Chrome with phone emulation:
it("should open yandex.ru with emulation of 2G-connection", async function ({ browser }) {
// Emulate a 2G connection
await browser.throttle("Good2G");
await browser.url("https://yandex.ru");
});