Simulate network conditions for Maestro tests
Set a network profile for your Maestro builds on BrowserStack App Automate to test your app under offline mode, 3G, 4G, or a custom network condition.
You can run your Maestro tests on BrowserStack real devices under different network conditions. Choose a predefined network profile, or create a custom profile with your own bandwidth, latency, and packet loss values. Both options work on Android and iOS devices.
To set a network condition, add the networkProfile or customNetwork parameter to the payload of the Maestro build API request.
The following table shows the network conditions you can set and their support on each OS:
| Network condition | Parameter | Value | Android | iOS |
|---|---|---|---|---|
| Device offline | networkProfile |
no-network |
Supported | Supported on iPhones with iOS 11 or later. Not supported on iPads. |
| Airplane mode | networkProfile |
airplane-mode |
Supported | Not supported. Use no-network instead. |
| Predefined network profile | networkProfile |
A profile name, such as 3g-umts-good or 4g-lte-advanced-good
|
Supported | Supported |
| Custom network profile | customNetwork |
Four comma-separated values, such as "1000,1000,100,1"
|
Supported | Supported |
- You can set the network condition only when the build starts, and it applies to the entire build. The mid-session
update_networkREST API isn’t available for Maestro, so you can’t change the network condition during a test. - Network profiles and custom network profiles are available only with a BrowserStack paid plan. For more information, see the pricing page.
Simulate device offline and airplane mode
To take the device offline or turn on airplane mode, set the networkProfile parameter to one of the following profiles:
| Profile name | Description |
|---|---|
no-network |
Turns off the network on the device to take it offline. |
airplane-mode |
Turns on airplane mode on the device. |
Select the OS of your device to view an example request:
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/android/build" \
-d '{"networkProfile": "no-network", "devices": ["Samsung Galaxy S23-13.0"], "app": "bs://APP_ID", "testSuite": "bs://TEST_SUITE_ID"}' \
-H "Content-Type: application/json"
- A few Android devices don’t support the
no-networkandairplane-modeprofiles. For the list of unsupported devices, see networkProfile. - If you set
airplane-modefor an iOS build, the build fails. To take an iOS device offline, use theno-networkprofile.
Simulate network conditions with a predefined profile
To simulate a network such as 3G or 4G, set the networkProfile parameter to one of the following profiles:
| Profile name | Bandwidth in/out (Kbps) | Latency (ms) | Packet loss (%) |
|---|---|---|---|
2g-gprs-good |
50/30 | 500 | 1 |
2g-gprs-lossy |
30/20 | 650 | 2 |
edge-good |
250/150 | 300 | 0 |
edge-lossy |
150/100 | 500 | 1 |
3g-umts-good |
400/100 | 100 | 0 |
3g-umts-lossy |
200/50 | 200 | 1 |
3.5g-hspa-good |
1800/400 | 100 | 0 |
3.5g-hspa-lossy |
900/200 | 190 | 1 |
3.5g-hspa-plus-good |
7000/1500 | 100 | 0 |
3.5g-hspa-plus-lossy |
2000/600 | 130 | 1 |
4g-lte-good |
18000/9000 | 100 | 0 |
4g-lte-high-latency |
18000/9000 | 3000 | 0 |
4g-lte-lossy |
7000/3000 | 120 | 1 |
4g-lte-advanced-good |
25000/18000 | 80 | 0 |
4g-lte-advanced-lossy |
15000/10000 | 70 | 1 |
A 5G profile isn’t available. To test your app on the fastest network, use the 4g-lte-advanced-good profile.
Select the OS of your device to view an example request:
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/android/build" \
-d '{"networkProfile": "4g-lte-advanced-good", "devices": ["Samsung Galaxy S23-13.0"], "app": "bs://APP_ID", "testSuite": "bs://TEST_SUITE_ID"}' \
-H "Content-Type: application/json"
Simulate network conditions with a custom profile
To simulate a network condition that the predefined profiles don’t cover, set the customNetwork parameter. Pass four comma-separated values in the following order:
| Position | Value | Unit |
|---|---|---|
| 1 | Download speed | Kbps |
| 2 | Upload speed | Kbps |
| 3 | Latency | ms |
| 4 | Packet loss | % |
For example, "customNetwork": "1000,1000,100,1" sets a download and upload speed of 1000 Kbps. It also sets a latency of 100 ms and a packet loss of 1%.
Select the OS of your device to view an example request:
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/android/build" \
-d '{"customNetwork": "1000,1000,100,1", "devices": ["Samsung Galaxy S23-13.0"], "app": "bs://APP_ID", "testSuite": "bs://TEST_SUITE_ID"}' \
-H "Content-Type: application/json"
Troubleshoot build errors
BrowserStack validates the network settings when you start the build. If a value isn’t valid, the build fails with one of the following errors:
| Error | Cause | Fix |
|---|---|---|
[BROWSERSTACK_INVALID_NETWORK_PROFILE] 'airplane-mode' is not supported on iOS. You can use 'no-network' network profile to send the device offline. |
You set "networkProfile": "airplane-mode" for an iOS build. |
Use "networkProfile": "no-network" instead. |
Incorrect arguments set in customNetwork capability |
The customNetwork value isn’t four valid comma-separated numbers. |
Pass the values in the order download speed, upload speed, latency, and packet loss, for example "1000,1000,100,1". |
Related topics
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!