Simulate network conditions

Simulate different network connections and conditions to test the performance of your apps when testing on BrowserStack device cloud. Under default network settings, each device in your test runs will have unhindered WiFi connection with Internet connectivity.

With Network simulation, you can change the WiFi connection to simulate the speeds of a network profile such as 2G or 3G which controls bandwidth, latency and packet loss. You can also simulate no internet using “no-network” network profile.

Use the browserstack.networkProfile capability to simulate different network conditions.

Capability Description Value
browserstack.networkProfile Simulate different network conditions from the list of existing network profiles < profile-name >
E.g. 2g-gprs-good, 2g-gprs-lossy, 3g-umts-good etc.

Example:

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("browserstack.networkProfile", "2g-gprs-good");
var capabilities = {
	'browserstack.networkProfile': '2g-gprs-good'
}
DesiredCapabilities capability = new DesiredCapabilities();
capability.SetCapability("browserstack.networkProfile", "2g-gprs-good");
$capabilities = new DesiredCapabilities();
$capabilities->setCapability("browserstack.networkProfile", "2g-gprs-good");
desired_cap = {
	'browserstack.networkProfile': '2g-gprs-good'
}
desired_caps = {
    'browserstack.networkProfile': '2g-gprs-good'
}

List of supported network 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
2gedge-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
no-network 0 0 0
airplane-mode (Android only) 0 0 0
Reset Set network settings to Browserstack’s default configuration    

Switch to a network profile in the middle of your test run

Use our REST API if you want to switch between different network profiles in the middle of your test run.

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -H "Content-Type: application/json" -d '{"networkProfile":"4g-lte-good"}' -X PUT "https://api-cloud.browserstack.com/app-automate/sessions/<sessionid>/update_network.json"
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"

Get session id using driver.session_id once the driver is created

Simulate a custom network condition

If you want to simulate a custom network condition, use the browserstack.customNetwork capability:

Capability Description Value
browserstack.customNetwork Simulate the custom network condition download speed (kbps), upload speed (kbps), latency (ms), packet loss (%)
E.g. “1000, 1000, 100, 1”
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("browserstack.customNetwork", "1000, 1000, 100, 1");
var capabilities = {
	'browserstack.customNetwork': '1000, 1000, 100, 1'
}
DesiredCapabilities capability = new DesiredCapabilities();
capability.SetCapability("browserstack.customNetwork", "1000, 1000, 100, 1");
$capabilities = new DesiredCapabilities();
$capabilities->setCapability("browserstack.customNetwork", "1000, 1000, 100, 1");
desired_cap = {
	'browserstack.customNetwork': '1000, 1000, 100, 1'
}
desired_caps = {
    'browserstack.customNetwork': '1000, 1000, 100, 1'
}
Note: Network profile and custom network feature for app testing is only available with a BrowserStack Paid plan. View details.

Switch to a custom network profile in the middle of your test run

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"

Get session id using driver.session_id once the driver is created

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