Skip to main content

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
    }
note

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 NameDownload SpeedUpload SpeedLatency
2g-gprs-poor20 Kbps6 Kbps1000 ms
2g-gprs-good50 Kbps16 Kbps500 ms
3g-umts-poor200 Kbps64 Kbps400 ms
4g-lte-poor1 Mbps500 Kbps200 ms
3g-umts-good5 Mbps2 Mbps100 ms
4g-lte-good15 Mbps7 Mbps70 ms
4g-lte-advanced-good25 Mbps12 Mbps20 ms
defaultNANANA

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")
caution
  • Wrong Capability Name or Value: Providing an incorrect capability value results in a bad request error with a descriptive message.
  • LambdaHook Error: If you pass any wrong value in LambdaHook,you will receive an error message.

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! 🙂