Network Throttling
Real Devices Only
With Sauce Labs Network Throttling, you can simulate and reproduce different network scenarios on iOS and Android, ensuring that your mobile application performs optimally under a huge variety of network conditions. From replicating slow network speeds to mimicking offline states, high latency, or connection disruptions, this feature allows you to identify network-related performance issues early in your pipeline.
In combination with our Network Traffic Capture functionality to record network traffic, you have the tools to replicate and troubleshoot any performance concerns stemming from network operations.
What You'll Need
- A Sauce Labs paid account (Log in)
- Access to our Real Devices (iOS/Android)
Supported Network Conditions
The following table shows the allowed range of supported network condition parameters:
Network Condition | Parameter | Range |
---|---|---|
Download speed | downloadSpeed | 0 - 50000 kbps |
Upload speed | uploadSpeed | 0 - 50000 kbps |
Latency | latency | 0 - 3000 ms |
Packet loss | loss | 0 - 100 % |
Only specified parameters will undergo conditioning, allowing for flexibility in customizing network simulations to your precise testing needs.
Predefined Network Profiles
The following table shows the predefined network profiles along with their corresponding parameter values supported on Sauce Labs:
Network Profile | ID | Download Speed (kbps) | Upload Speed (kbps) | Latency (ms) | Packet Loss (%) |
---|---|---|---|---|---|
No Throttling | no-throttling | - | - | - | - |
No Network | no-network | 0 | 0 | 0 | 100 |
2G Packet Loss | 2G-packet-loss | 100 | 50 | 500 | 10 |
2G | 2G | 200 | 100 | 300 | 1 |
3G Slow | 3G-slow | 500 | 250 | 200 | 1 |
3G Fast | 3G-fast | 7000 | 2500 | 100 | - |
4G Slow | 4G-slow | 8000 | 4000 | 100 | - |
4G Fast | 4G-fast | 25000 | 15000 | 30 | - |
Automated Testing
Appium - Capability
To use the Sauce Labs Network Throttling feature in your automated Appium test, you can add the Sauce-specific capability networkConditions to provide custom network conditions for the entire session. Alternatively, you can use the Sauce-specific capability networkProfile to apply one of the predefined network profiles to your session.
MutableCapabilities capabilities = new MutableCapabilities();
//...
MutableCapabilities sauceOptions = new MutableCapabilities();
// network conditions
sauceOptions.setCapability("networkConditions", ImmutableMap.of(
"downloadSpeed", 5000,
"uploadSpeed", 3000,
"latency", 200,
"loss", 2,
));
// OR
// network profile
sauceOptions.setCapability("networkProfile", "2G");
capabilities.setCapability("sauce:options", sauceOptions);
Appium - executeScript
To change your desired network conditions dynamically any time during your automated Appium test, use our Sauce-specific scripts sauce: network-conditions and sauce: network-profile with Appium's Execute Script.
driver.executeScript("sauce: network-conditions", ImmutableMap.of(
"downloadSpeed", 5000,
"uploadSpeed", 3000,
"latency", 200,
"loss", 2,
));
driver.executeScript("sauce: network-profile", "4G-fast");
To disable network throttling, use the predefined network profile no-throttling
:
driver.executeScript("sauce: network-profile", "no-throttling");
Live Testing
Apply network throttling dynamically to your manual Live tests by selecting a predefined profile or by providing network conditions.
- In the live test window, in the left toolbar, click Throttle Network to open the network throttling tool.
- Select a predefined profile from the dropdown to start the network throttling.
An active network throttling is indicated by the pulsing red dot on the top left of the Throttle Network tool.
- Click on the pulsing red dot to pause the network throttling. A paused throttling is indicated by the pause icon.
Upcoming
- Apply network throttling to your native Espresso and XCUITest tests
Limitations
- iOS network throttling is supported on iOS/iPadOS 14.0 and above.
- Android network throttling is supported on Android 10 and above.
More Information
- Use Network Capture to debug the failures in the app.
- Check out the Java Appium examples for iOS and Android.