Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & App Percy

Simulate mobile network conditions

BrowserStack App Automate enables you to test mobile applications under various network conditions such as offline mode, airplane mode, and network profiles such as 3g-umts-good and 4g-lte-good on BrowserStack’s real mobile device cloud.

To simulate network conditions, you can use any of the pre-defined network profiles or create a custom network profile.

Important: The predefined and custom network profile features are available only in the App Automate Paid plan.

In this guide, you will learn how to:

  1. Simulate device offline and airplane mode
  2. Simulate network conditions using predefined network profiles
  3. Simulate network conditions using a custom network profile
  4. Reset the device to default network configuration

Simulate device offline and airplane mode

Add following network profiles as the value to the key in your test script to simulate offline or airplane mode of a device.

Profile Name Description
no-network Disables network on the device to put it in the offline mode.
Note: This profile is supported on:
- Android devices - all Android OS versions
- iPhones - iOS 13 and above.
airplane-mode Enables the airplane mode setting on an Android device to put it in the airplane mode.
Note: This profile is supported on all Android devices except the devices listed here under the Capabilities Reference section

Set network mode at the start of session

To set the network mode at the start of the session, add the network profiles, no-network or airplane-mode, as a value to the capability in your test script:

DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("networkProfile", "no-network");
var capabilities = {
	'bstack:options' : {
		"networkProfile" : "no-network",
	},
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("networkProfile", "no-network");
$caps = array(
    'bstack:options' => array(
        "networkProfile" => "no-network",
    ),
)
desired_cap = {
	'bstack:options' : {
		"networkProfile" : "no-network",
	},
}
capabilities = {
    'bstack:options' => {
        "networkProfile" => "no-network",
    },
}
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserstack.networkProfile", "no-network");
var capabilities = {
"browserstack.networkProfile" : "no-network",
}
AppiumOptions capabilities = new AppiumOptions();
capabilities.AddAdditionalCapability("browserstack.networkProfile", "no-network");
$caps = array(
"browserstack.networkProfile" => "no-network"
)
desired_cap = {
"browserstack.networkProfile" : "no-network"
}
caps = Selenium::WebDriver::Remote::Capabilities.new
caps["browserstack.networkProfile"] = "no-network"

Set network mode in the middle of session

While your session is running, run the following cURL command in your terminal to set the network mode in the middle of the session:

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -H "Content-Type: application/json" -d '{"networkProfile":"no-network"}' -X PUT "https://api-cloud.browserstack.com/app-automate/sessions/<sessionid>/update_network.json"

Replace <sessionid> with the ID of your ongoing test session. To get the session ID of your ongoing test, check out the code snippets in the get session ID section.

Simulate network conditions using predefined network profiles

Add any of the predefined network profiles, provided by BrowserStack, as the value to the key in your test script to simulate various network conditions. Please, note that this feature is not supported for proxy-unaware applications.

Set predefined network profile at the start of session

Add the predefined network profile as a value to the capability to set a predefined network profile at the start of the session.

DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("networkProfile", "2g-gprs-good");
var capabilities = {
	'bstack:options' : {
		"networkProfile" : "2g-gprs-good",
	},
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("networkProfile", "2g-gprs-good");
$caps = array(
    'bstack:options' => array(
        "networkProfile" => "2g-gprs-good",
    ),
)
desired_cap = {
	'bstack:options' : {
		"networkProfile" : "2g-gprs-good",
	},
}
capabilities = {
    'bstack:options' => {
        "networkProfile" => "2g-gprs-good",
    },
}
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserstack.networkProfile", "2g-gprs-good");
var capabilities = {
	'browserstack.networkProfile' : '2g-gprs-good'
}
AppiumOptions capabilities = new AppiumOptions();
capabilities.AddAdditionalCapability("browserstack.networkProfile", "2g-gprs-good");
$caps = array(
    "browserstack.networkProfile" => "2g-gprs-good"
)
desired_cap = {
	"browserstack.networkProfile" : "2g-gprs-good"
}
caps = Selenium::WebDriver::Remote::Capabilities.new
caps["browserstack.networkProfile"] = "2g-gprs-good"

Set predefined network profile in the middle of session

While your session is running, run the following cURL command in your terminal to add the predefined network profiles. To see the predefined network profiles, check out this section.

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -H "Content-Type: application/json" -d '{"networkProfile":"2g-gprs-good"}' -X PUT "https://api-cloud.browserstack.com/app-automate/sessions/<sessionid>/update_network.json"

Replace <sessionid> with the ID of your ongoing test session. To get the session ID of your ongoing test, check out the code snippets in the get session ID section.

Supported predefined network profile

The following table shows the supported predefined network profiles available in BrowserStack:

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
reset Removes predefined or custom network settings from the device and sets it back to its original state. N/A N/A

Simulate network conditions using a custom network profile

Create a custom network profile using supported parameters to simulate network condition. Please, note that this feature is not supported for proxy-unaware applications.

Set custom network condition at the start of session

Add the custom network parameters to the capability to set a custom network profile at the start of the session, as shown in the following tab:

DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("customNetwork", "1000,1000,100,1");
var capabilities = {
	'bstack:options' : {
		"customNetwork" : "1000,1000,100,1",
	},
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("customNetwork", "1000,1000,100,1");
$caps = array(
    'bstack:options' => array(
        "customNetwork" => "1000,1000,100,1",
    ),
)
desired_cap = {
	'bstack:options' : {
		"customNetwork" : "1000,1000,100,1",
	},
}
capabilities = {
    'bstack:options' => {
        "customNetwork" => "1000,1000,100,1",
    },
}
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserstack.customNetwork", "1000,1000,100,1");
var capabilities = {
"browserstack.customNetwork" : "1000,1000,100,1",
}
AppiumOptions capabilities = new AppiumOptions();
capabilities.AddAdditionalCapability("browserstack.customNetwork", "1000,1000,100,1");
$caps = array(
"browserstack.customNetwork" => "1000,1000,100,1"
desired_cap = {
"browserstack.customNetwork" : "1000,1000,100,1"
}
caps = Selenium::WebDriver::Remote::Capabilities.new
caps["browserstack.customNetwork"] = "1000,1000,100,1"

Set custom network profile in the middle of session

While your session is running, run the following cURL command in your terminal to set a custom network profile in the middle of the session. To see the parameters of a custom network profile, check out this section.

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -H "Content-Type: application/json" -d '{"customNetwork":"1000,1000,100,1"}' -X PUT "https://api-cloud.browserstack.com/app-automate/sessions/<sessionid>/update_network.json"

Replace <sessionid> with the ID of your ongoing test session. To get the session ID of your ongoing test, check out the code snippets in the get session ID section.

Supported custom network profile parameters

The following table shows parameters to create a custom network profile:

Parameter Range
Download speed 0-50000 kbps
Upload speed 0-50000 kbps
Latency 0-3000 ms
Packet loss 0-99%

Reset device to default network configuration

Use the following cURL request to set the value for networkProfile or customNetwork keys to reset to remove the active network condition from the device and set it back to the default network.

  • Remove configured network mode (no-network, airplane-mode) and network condition (2G, 3G, etc.) from a device:
    curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -H "Content-Type: application/json" -d '{"networkProfile":"reset"}' -X PUT "https://api-cloud.browserstack.com/app-automate/sessions/<sessionid>/update_network.json"
    
  • Reset custom network condition from a device:
    curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -H "Content-Type: application/json" -d '{"customNetwork":"reset"}' -X PUT "https://api-cloud.browserstack.com/app-automate/sessions/<sessionid>/update_network.json"
    

    Replace <sessionid> with the ID of your ongoing test session. To get the session ID of your ongoing test, check out the code snippets in the get session ID section.

Need some help?

If you have any queries, get in touch with us.

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

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy