menu

Edition 72

Simulating Slow Internet Connections on Android Emulators with Appium

Java
Android
Emulators

Ensuring that software works for non-ideal cases is much more work than programming the happy-path behavior, and is perhaps more critical. Since app developers need to ensure apps work in all situations, app testers must test these situations too!

While worldwide cellular networks are growing and improving, even in the most developed cities you will encounter bad network connections throughout the day. Appium has the ability to adjust the network connectivity of Android Emulators with a simple desired capability:

DesiredCapabilities caps = new DesiredCapabilities();
// ... regular desired capabilities
caps.setCapability("networkSpeed", "lte");

The networkSpeed desired capability will change the upload and download speed accessible to the emulator. The following values can be set, all speeds are in kbps:

  • gsm - GSM/CSD (up: 14.4, down: 14.4).
  • scsd - HSCSD (up: 14.4, down: 57.6).
  • gprs - GPRS (up: 28.8, down: 57.6).
  • edge - EDGE/EGPRS (up: 473.6, down: 473.6).
  • umts - UMTS/3G (up: 384.0, down: 384.0).
  • hsdpa - HSDPA (up: 5760.0, down: 13,980.0).
  • lte - LTE (up: 58,000, down: 173,000).
  • evdo - EVDO (up: 75,000, down: 280,000).
  • full - No limit, the default (up: 0.0, down: 0.0).

This desired capability will work, even if the emulator has already been launched, prior to the test being run.

If you start the emulators using Appium, you can also control the latency of the emulator network connection. This can be done by specifying an extra argument to be used when starting the emulator. In this case, the -netdelay argument, which can be used via the avdAgrs desired capability. More information on the -netdelay option can be found here: https://developer.android.com/studio/run/emulator-commandline.

That's it for this week, we're busily preparing for AppiumConf 2019 and hope to see you there!

Discuss this Edition