network-visualization-network-testing
April 14, 2022

Network Virtualization Testing With Perfecto & Appium

Continuous Testing
Mobile Application Testing

All mobile application developers and testers experience the same challenge: ensuring the application will respond gracefully and as expected no matter where their mobile applications are being used and under which conditions. Such conditions include airplane mode, no network connectivity, poor network connection and 2G, 3G or 4G network speeds. 

If a user is using a banking application and goes into an elevator or a subway, does your application handle that scenario gracefully? By testing real end user conditions, teams can ensure a high-quality mobile application user experience, advanced test automation coverage (and ensuring they will test the application before their users do).

With Perfecto and Appium, you can simulate all the network scenarios we have listed above and more. You can use the out-of-the box-network user profiles to simulate cellular network speeds. You also have the flexibility to create your own custom network conditions by manipulating metrics like latency, packet loss and bandwidth in and out. We make it easy to simulate the cellular networks with user profiles, and if you need custom control, you have easy access to that as well. 

This blog will explore network virtualization testing with the integration of Perfecto and Appium in more detail. 

Related Resources >> User Simulation Testing for Mobile Apps

Back to top

Network Virtualization Testing with Perfecto and Appium: Capabilities

Perfecto provides advanced network virtualization on top of open source Appium. Network virtualization plus additional Perfecto capabilities enables you to:

  1. Disable Wi-Fi or enable airplane mode
  2. Simulate network conditions using predefined profiles (2G, 3G, 4G)
  3. Simulate network conditions using a custom network profile (e.g., latency (ms), packet loss (%), Bandwidth in and out (kbps))
  4. Get the current network settings
  5. Update network conditions or reset the device to default network configuration

The Perfecto continuous testing platform allows you to simulate these different network conditions in a manual test or an automated process by using Appium on both iOS and Android. We will dive into this below. For manual testing, you can also use the Perfecto UI and the “Network Virtualization” widget:

A close-up of a cell phone

Description automatically generated with medium confidence

Back to top

Network Virtualization, Simplified

When it comes to embedding network virtualization functionality using real mobile devices, Perfecto provides a testing platform with advanced network simulation functionality built on top of open-source Appium. Perfecto provides an easy to call method that can be added to your Appium scripts in about 5 to 10 lines of code, depending on what you are trying to do. 

Below I call the method in “startNetworkVirtualization” and send the necessary parameters to the method that implements the actual lines of code shown in a later snapshot in this blog.

Text

Description automatically generated

You can reference the documentation for a comprehensive explanation here.

Back to top

Perfecto User Profiles

Perfecto makes testing network conditions easy by providing you with a number of user profile network conditions already packaged for you and ready to use. These enable easily simulating different cell network speeds from 2G to 4G. 

Here is a small sample of User Profiles:

Network to useLatency (ms)Bandwidth-inBandwidth-out
2g_gprs_poor70030/202
3g_umts_average140300/500
3.5g_hspa_poor190900/201
4g_lte_poor1207000/30001
4g_lte_average10010000/44000
Back to top

Network Condition Customization

You can also customize your network conditions. If you want to customize your own network speeds and other variables for advanced user scenarios you have that flexibility. It is as easy as providing the parameter and the value you want the parameter to simulate. Some of the more popular parameters include:

  • packetLoss – Network packet loss
  • latency – Latency applied on packets in the Network
  • bandwidth.in/bandwidth.out – Limitation of download and upload network bandwidth from the device
  • delayJitter – Random latency variation

You can enable parameters when starting or stopping the network simulation that will capture Single User Performance information if you want to understand the HTTP traffic. You can generate HAR (Http Archive files) and PCAP or Packet capture files. Examples of these parameters can also be seen in the code snippet below. You can also capture device vitals using other built in methods provided by the Perfecto Platform. For understanding the load performance time, use UX timers. 

Look at the following code samples to see examples of using the out-of-the-box user profiles, updating the network settings, disabling the Wi-Fi, turning on airplane mode, and more. Below shows how you can call each command in a method. In the snippet above we show examples of calling one of the methods in Appium and Java.

Alt text: Code sample for network virtualization testing with Perfecto

After the test has been executed, you will be able to see each line of code and corresponding action at the test step level within the Perfecto UI. You also have a rich set of artifacts to select from for testing, such as video recordings, Snapshots, Device Vitals, PCAP files, HAR files, Crash logs and other relevant data like page load time duration. Testers can quickly find the root cause of any issues they are investigating with all this data. You can share the data amongst your teammates so they can reproduce any issues quickly.Graphical user interface

Description automatically generated

Bottom Line

Perfecto is the continuous testing platform that is always on and always ready to run. Perfecto provides the devices, desktop browser combinations and the infrastructure that can scale to support hundreds and thousands of automated tests every day.

Perfecto also supports a wide range of advanced automation scenarios for iOS and Android on top of open-source Appium. In addition to network virtualization testing, these include:

  • Biometric authentication – Face and Fingerprint ID
  • Voice assistance testing/Audio injection – Audio to Text and Text to Audio
  • Image Injection (QR code, Barcode, Check Scanning, etc).
  • Optical character recognition (OCR) – Text and Image Analysis
  • Advanced Authentication (2FA, OTP, Multidevice Flows)
  • Apple pay and Google Pay
  • Location Injection/Geolocation
  • And more.

These can be run and used as simply as the examples provided in the blog. If you’d like to have details on these, please reference our online documentation.

Watch Network Virtualization Testing in Action 

See a custom demo of network virtualization testing with Perfecto and Appium.  

 Get My Demo

Back to top