id | title | hide_title | sidebar_label | description | keywords | url | site_name | slug | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
app-auto-network-throttling |
Network Throttling for Appium tests |
false |
Network Throttling |
Now validate your mobile applications over low latency networks (2G/3G/LTE) or in offline mode with varying upload and download speeds. LambdaTest empowers you to simulate these mobile network conditions through its desired capabilities, ensuring comprehensive testing of your mobile applications. |
|
LambdaTest |
app-auto-network-throttling/ |
import CodeBlock from '@theme/CodeBlock'; import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys";
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify({ "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [{ "@type": "ListItem", "position": 1, "name": "LambdaTest", "item": "https://www.lambdatest.com" },{ "@type": "ListItem", "position": 2, "name": "Support", "item": "https://www.lambdatest.com/support/docs/" },{ "@type": "ListItem", "position": 3, "name": "Network Throttling", "item": "https://www.lambdatest.com/support/docs/app-auto-network-throttling/" }] }) }} ></script>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.
- 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.
:::
- LambdaHook: Dynamically alter the network profile within the test session using the following LambdaHook:
driver.execute_script("updateNetworkProfile=3g-umts-good")
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 |
- 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 }" )
- 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")
-
To initialize tests in offline mode, set the
networkProfile
capability tooffline
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")
- LambdaHook: You can also switch to offline mode during the test execution with the following command:
driver.execute_script("updateNetworkProfile=offline")
-
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 <span className="doc__lt" onClick={() => window.openLTChatWidget()}>24/7 Customer chat support. You can also drop us a mail at support@lambdatest.com. Happy testing! 🙂