Testing Android/IOS apps under network conditions
Tags: android, ios, mobiletesting, functionaltesting
Published: 2020-07-06 17:45:19

---
title: Testing Android/IOS apps under network conditions
published: true
date: 2020-07-06 17:40:35 UTC
tags: Android,iOS,MobileTesting,Functionaltesting
canonical_url: https://automationhacks.io/2020/07/06/testing-android-ios-apps-under-network-conditions/
---

![](https://automationhacksblog.files.wordpress.com/2020/07/leon-seibert-2m71l9fa6mg-unsplash.jpg?w=1024)<figcaption>Photo by <a href="https://unsplash.com/@yapics?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Leon Seibert</a> on <a href="https://unsplash.com/s/photos/slow-internet?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption>

It’s 2020 and mobile phones are ubiquitous. Everyone has it and uses it constantly. Most of the time as testers, we test our mobile apps in office Wifi conditions with an ideal high-quality internet connection in terms of app performance.

However, we all know the real-life network is far from this ideal. We/our consumers mostly use our apps on the Go (traveling in a bus, sometimes even when walking) and the network conditions will rarely be the conditions that we test under.

In such cases, a carefully thought out and tailored UX can be the difference between a happy consumer who would like to use your app again Vs a frustrated or confused consumer who eventually uninstalls the app and move on to something else.

So hopefully, by now you must feel convinced that it is quite **important** to get _feedback about the quality of your app under different network conditions_.

However, since we can’t really travel to different parts of the office/home/city in search of such pockets of bad network areas every time we want to test right?

Luckily both Apple/Google gives us ways to simulate these network conditions. Let’s take a look at how:

## Simulate network conditions on IOS

Apple provides a handy utility to help to simulate network conditions called **network conditioner**

### Setup network conditioner

Connect your iPhone real device to your laptop via USB or start the simulator via Xcode

Open **Windows > Devices and Simulator**

![](https://automationhacksblog.files.wordpress.com/2020/07/nwc_1.png?w=1024)

Under Device conditions select **Network Link**

![](https://automationhacksblog.files.wordpress.com/2020/07/nwc_2.png?w=1024)

Once selected, You can choose a network in the range of _Very poor to Edge, 2G, 3G, and what not_. ![🥳](https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/72x72/1f973.png)

![](https://automationhacksblog.files.wordpress.com/2020/07/nwc_3.png?w=1024)

Also, Once this setting has been set via Xcode, You can now access **Developer** section in your iPhone settings and enable as well as change these conditions easily

```
Remember to enable the network conditioner and then choose whichever condition you want to test on.
```

![](https://automationhacksblog.files.wordpress.com/2020/07/nwc_4.png?w=528)

![](https://automationhacksblog.files.wordpress.com/2020/07/nwc_5.png?w=528)

## Simulate network conditions on Android 

### On an emulator

If you are running an emulator image via android studio, then changing the network speed is as simple as going to **Emulator settings > Cellular > Select Network Type > Select Signal Strength** as per your test scenario requirement

![](https://automationhacksblog.files.wordpress.com/2020/07/android_studio_cellular.png?w=1024)

You can also control this [setting via adb](https://developer.android.com/studio/run/emulator-commandline.html) by updating `netdelay` option of **emulator utility** with values like `gprs`, `edge`

```
~/Library/Android/sdk/emulator/emulator -avd <avd\_name> -netdelay none -netspeed full
```

### On a real device

If you real device has a SIM, then you can go into **Network settings** (Wifi & internet on Android 10) > **SIM and network** and then select the **Preferred network type** to either 2G, 3G or 4G

Another possible approach could be to use a proxy tool to throttle network calls by introducing some programmatic delays. Though not the most realistic way to set this up but nonetheless effective. More details on this in a future post.

## Conclusion

Next time when you feel your app works perfectly under perfect network conditions, maybe try using one of these above to test the app under a less reliable network and see if the app still offers a graceful experience to the user.

If you found this useful, Do share it with a friend or colleague. Until next time, Happy testing.

## Further read/References

In case you want to read a bit more about this topic, feel free to check out any of these excellent articles for more details.

- [https://developer.android.com/studio/run/emulator-commandline.html](https://developer.android.com/studio/run/emulator-commandline.html)
- [https://stackoverflow.com/questions/7026251/simulate-low-network-connectivity-for-android](https://stackoverflow.com/questions/7026251/simulate-low-network-connectivity-for-android)
- [https://appiumpro.com/editions/63-capturing-android-emulator-network-traffic-with-appium](https://appiumpro.com/editions/63-capturing-android-emulator-network-traffic-with-appium)
- [https://blog.bam.tech/developer-news/simulate-poor-network-test-mobile-apps-device](https://blog.bam.tech/developer-news/simulate-poor-network-test-mobile-apps-device)