logo logo

A TestProject Addon for Adjusting Android Emulator Network Speed

main post image

One common requirement for testing apps that are supposed to run in a variety of contexts is related to the device-under-test’s network speed. An app that runs just fine on an LTE connection will not necessarily run with the same quality on a GPRS or EDGE connection. So how do you make sure that your app works well across all types of connections?

There are of course services out there that will give you the ability to test on actual devices connected to actual networks in different locations and at different speeds. Sometimes, though, all you need is to throttle the network connection to your test device to see how your app will behave under different network conditions. Appium provides a way to do this for Android devices. Well, not all devices–it only works for emulators. Luckily, TestProject supports automation of Android Emulators, so if network speed modulation is an attractive feature for you, you can make it work with TestProject and Appium.

If you were using Appium directly, it’s fairly easy to adjust the network speed of an Android Emulator in code. For example, in Java, you could run a command like the following:

driver.setNetworkSpeed(NetworkSpeed.EDGE);

This code uses a Java enum class that holds values for all the different speeds available. They are:

  • GSM
  • SCSD
  • GPRS
  • EDGE
  • UMTS
  • HSDPA
  • LTE
  • EVDO
  • FULL

(Here, “FULL” means no network throttling. And if you were using Appium directly, you could also set this with a desired capability.)

With the new Android Emulator Network Speed Modulator Addon, you can add a global action that prompts for one of these speeds. All you have to do is type in the speed you want (in exactly the format as shown above, using all caps), and when the action is run, the network speed will be adjusted. This actually changes it for the emulator as a whole (not just for the course of a test), so if you want to reset the speed to FULL, make sure you do that at some subsequent point (I chose to do it both before and after the rest of the test, to make sure that if the state is messed up from a previous test, I still start out each test at full speed).

That’s really all there is to it! 😉 Of course, the emulator is still using the host’s network, so these “synthetic” speeds will all be dependent on the host’s network. If the host’s network is slower than LTE speeds, for example, you won’t get an accurate rendition of the app’s performance at LTE (or FULL) speeds. Still, it’s a very useful tool for seeing how long it takes for your app to load a webpage or make calls to a backend API, especially for users that have devices operating at much slower network speeds than you as an early adopter of technology and developer or tester of your app!

The following diagram illustrates how you can make sure your Mobile app works well across all connection types using the TestProject Speed Modulator Addon:

A TestProject Addon for Adjusting Android Emulator Network Speed

Which kind of Addon would you like to see next? Share your ideas in the comments below!
In the meantime, check out some previous Addons I’ve already created and shared with the community 👉

 

Avatar

About the author

Jonathan Lipps

Jonathan has been making things out of code as long as he can remember. Jonathan is the architect and project lead for Appium, the popular open source automation framework. He is also the founding Principal of Cloud Grey, a consulting firm devoted to helping clients leverage the power of Appium successfully. He has worked as a programmer in tech startups for over 15 years, but is also passionate about academic discussion. Jonathan has master’s degrees in philosophy and linguistics, from Stanford and Oxford respectively. Living in Vancouver, he’s an avid musician, and also writes on the philosophy of technology.

Jonathan also writes the weekly newsletter and blog Appium Pro, which delivers fantastic Appium-related tips and tutorials straight to your inbox every Wednesday.

Join TestProject Community

Get full access to the world's first cloud-based, open source friendly testing community. Enjoy TestProject's end-to-end test automation Platform, Forum, Blog and Docs - All for FREE.

Join Us Now  

Leave a Reply

popup image

Best In Class Java and C# SDK

Join thousands of automation developers using TestProject to supercharge open source testing, with a Selenium and Appium SDK, supporting Java and .NET Core (C#)!
Sign Up Now right arrow
FacebookLinkedInTwitterEmail