In the world of digitization, the smartphone becomes the basic need of humans. More than 3 billion users are using smartphones across the globe. Whereas more than a million mobile applications present on Google Play Store, Apple App Store, and other application stores. The number of developers is developing mobile applications whereas Software Tester is involved in assuring the quality of Mobile App using manual or by doing automation.

No internet android and chrome

As Software tester verifying and delivering the quality mobile application is a cumbersome task, the reason behind this device fragmentation in the smartphone, device screen size,  hardware dependency, Operating system, and verifying network-related scenario.  

Here we are going to learn how to automate network connection offline scenario using appium on android and ios platform and its importance. As we all know mobile applications behave unusually when we move to a slow network or out of the network. I think we all have experienced it in the subway, underground metro, parking lot, or elevator. Some times mobile application get crashed due to poor handling of network scenarios may lead to the potential of the customer as well. The best way to avoid this test a mobile application using real comprehensive scenario testing.

Appium is a widely used open-source mobile application automation tool. I used Java and Appium for automation purposes so you need a prior understanding of Appium and basics of Java language.

Turn Off the Network Connection in Android Device:

1. Toggle Wi-Fi in Android Network if Mobile Network is Not Available:

On the Latest Android OS platform, you can not toggle Airplane mode by code. You will get an exception as below

2. To achieve this on Appium Java Client  7.2.0 above version you can use the below code.

(Note: Do not add selenium dependency in the project as otherwise, you will get an exception issue )

3. Use ADB commands to Navigate Airplane Mode Menu and Toggle Airplane Mode:

Or You can navigate to Wifi Settings Of Android Device And Toggle Setting using Xpath of Locator:

Internet Connection Offline Scenario Automation in iOS devices:

   You can toggle Wi-Fi or data connection in Android devices using ADB commands or Appium in build commands. But in the case of the iOS platform, Appium does not provide direct commands for making internet connection offline. 

iOS mobile automation

If you are new in iOS application automation, then you might want to read the below article:

Appium v 1.7.1 setup on Mac OS Sierra for iOS Real device automation.

You can enable Airplane mode in the iOS device using Appium and by getting native app bundle id. You can get here the default bundle id list for iOS application according to the OS version. 

In the below code, we used two default bundle id one for the stock app and settings of the iOS device.

We simply switched app using the bundle identifier and performed Appium commands for enabling and disable Airplane Mode.

Here is the sample code snippet for enabling and Disable Airplane Mode in iOS:

Source link

Write A Comment