Network conditioning

Mostly, we test a mobile app in a perfect condition of best and fast network; however, in reality the devices might be moving and the network may be fluctuating between Edge connections (2G), 3G, or even LTE. Sometimes, the automation test has to run at a lower data speed or even test some offline functionality.

Appium exposes the driver.setConnection() method, which can help in setting the network condition between WiFi, airplane, data, or none. Any of the following statements can be used, based on which data connectivity you want to set up:

driver.setConnection(Connection.AIRPLANE);
driver.setConnection(Connection.WIFI);
driver.setConnection(Connection.DATA);
driver.setConnection(Connection.NONE);
driver.setConnection(Connection.ALL );

The connection is an enum that defines these bit masks:

Connection Type Bit Mask
NONE 0
AIRPLANE 1
WIFI 2
DATA 4
ALL 6

 

Once the value is set, it persists for the life of the driver instance, so we must reset it back to the data connectivity we want for the test suite.

On macOS, one can install the Network Link Conditioner app to simulate the various network conditions. It can be downloaded as part of the Hardware IO tools package (for more information visit: https://developer.apple.com/download/more/?q=Hardware%20IO%20Tools). The following screenshot shows what the app looks like. This helps simulate the network speed on the simulator. One thing to keep in mind is that it impacts the hosting device network speed as well, so we have to be careful while using it:

Profile lets you select between different network speeds, such as low latency and 3G:

However, on a real iOS device, it's already built in and can be accessed by navigating to Settings > Developer > Network link Conditioner.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.190.156.93