Change mobile state to offline mode/Airplane mode on Android and iOS?

How did you arrived the control center? I always get a point is not within the bounds of the screen exception, even though im inside the valid screen.
The maximum Y value to tap is 600 before the exceptions comes but the screensize of my iphone is 375x 667

Hi KalveeduVJ,

Can you please give the java code for ios11 realdevice to switch from offline to online and online to offline. and to navigate to the testing app .

I have found this in the appium documentation for appium.

http://appium.io/docs/en/commands/device/network/toggle-airplane-mode/#appium-clients

POST /session/:session_id/appium/device/toggle_airplane_mode

Is there any java example using this? How do we make the POST call on the driver?

Android:


iOS:
No standard way to do it, however one can emulate the normal user behaviour like it is described in https://appiumpro.com/editions/15

Thank you @mykola-mokhnach. I will give this a try.

One clarification question. The comment states that:
“This option only works up to Android 6.”

Any idea this will work for Android 7 or above?

Regarding Android 7+ this is OS-level limitation.

Although, you could try to do the same trick as for iOS - emulate user actions by opening system settings and switching the state there if you don’t care about the support of multiple devices

Any idea how to turn on/off network on android using Appium C# libraries?

In Appium Latest Java client you can do it using
To disable Wifi and Data in Android:
driver.setConnection(new ConnectionStateBuilder().withWiFiDisabled().withDataDisabled().build());
To enabled WiFI and Data in Android:
driver.setConnection(new ConnectionStateBuilder().withWiFiEnabled().withDataEnabled().build());
To Enable and Disable Airplane mode in iOS you can refer below article:
Internet Offline Scenario Automation on Android and iOS Mobile App