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... |