Network Throttling
In Appium testing, assessing your app's performance under diverse network conditions (2G/3G/LTE) and offline scenarios, is crucial. Fluctuating upload and download speeds can significantly impact your app's behavior across different devices.
LambdaTest simplifies testing by enabling simulation of diverse network conditions. Whether starting with defaults or custom profiles, these features replicate real-world scenarios, proving invaluable for Appium tests. The device maintains uninterrupted internet connectivity throughout, ensuring a reliable testing experience for your mobile applications.
Objectives
By the end of this guide, you will learn how to:
- Initialize a test session with predefined network profiles.
- Dynamically change network profiles during test execution using LambdaHooks.
- Define and implement custom network profiles.
- Reset the network profile to default settings.
Workflow
Initialization
- Capability: Initiate a test session with predefined network profiles using the
networkProfile
capability. Example:caps = {
"network": True,
"networkProfile": "2g-gprs-good" # Set the desired network profile
}
To utilize the networkProfile capability, ensure that you include network: True
in the capabilities
During Test Execution
-
LambdaHook: Dynamically alter the network profile within the test session using the following LambdaHook:
driver.execute_script("updateNetworkProfile=3g-umts-good")
-
Offline mode can be supported during test execution by using using the following LambdaHook (only for android):
driver.execute_script("updateNetworkProfile=offline")
Supported Network Profiles
Profile Name | Download Speed | Upload Speed | Latency |
---|---|---|---|
2g-gprs-poor | 20 Kbps | 6 Kbps | 1000 ms |
2g-gprs-good | 50 Kbps | 16 Kbps | 500 ms |
3g-umts-poor | 200 Kbps | 64 Kbps | 400 ms |
4g-lte-poor | 1 Mbps | 500 Kbps | 200 ms |
3g-umts-good | 5 Mbps | 2 Mbps | 100 ms |
4g-lte-good | 15 Mbps | 7 Mbps | 70 ms |
4g-lte-advanced-good | 25 Mbps | 12 Mbps | 20 ms |
default | NA | NA | NA |
Download speed is currently stable, expect additional feature updates shortly.
Custom Profiles
-
LambdaHook: Define and implement custom network profiles with LambdaHook by specifying the maximum download speed (kbps), maximum upload speed (kbps), and latency (ms) for the custom condition, as illustrated in the example.
driver.execute_script("customNetworkProfile: { \"downloadSpeed\": 500, \"uploadSpeed\" : 250, \"latency\": 100 }" )
Default/Reset network configuration
-
LambdaHook: Employ this webhook to seamlessly restore the device's network profile to its default state. Invocation of this LambdaHook removes any predefined or custom network settings, ensuring the device is reset to its original configuration.
driver.execute_script("updateNetworkProfile=default")
In case you have any questions, feel free to share them with us.Our experts are available on 24/7 Customer chat support. You can also drop us a mail at support@lambdatest.com. Happy testing! 🙂