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.

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")

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

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")

Offline Mode

Android

  • To initialize tests in offline mode, set the networkProfile capability to offline during session initiation:

    caps = {
    "network": True,
    "networkProfile": "offline" # Set to offline mode
    }
  • LambdaHook: You can also switch to offline mode during the test execution with the following command:

    driver.execute_script("updateNetworkProfile=offline")

iOS

  • LambdaHook: You can also switch to offline mode during the test execution with the following command:
    driver.execute_script("updateNetworkProfile=offline")

Toggle Offline/Online Mode via API

  • For both iOS and android devices you can use the offline/online mode API as well within the running test session:

    curl --location 'https://mobile-api.lambdatest.com/mobile-automation/api/v1/sessions/<session-id>/update_network' \
    --header 'Authorization: Basic <username:access_key>' \
    --header 'Content-Type: application/json' \
    --data '{"mode": "offline"}'
note
  • Network throttling results may vary sometimes based on multiple factors including network conditions and device performance.

  • 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 offline mode, live video will not be available for the duration of the test session.

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

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles