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

I do it exactly the way you said… Swipe the control up and click on airplane mode

What are the swiping co-ordinates u pass?As it needs to be precise i guess

@Mitesh_Agrawal thanks man it worked in android real device

Welcome Jagadeesh :smile:

I’m using ruby and I’m using


being by function:

def __swipe(start_x, start_y, end_x, end_y, duration = 1)
    swipe(:start_x => start_x, :start_y => start_y, :end_x => end_x, :end_y => end_y, :duration => duration*1000)

In ruby we can use % so that translate into floats, while in java I think its only possible to pass int so it may not even be possible, not sure.

Thanks Man…i’ll Check it out in java.

In Java Swipe Up:

Dimensions d=driver.manage().window().getSize();
int width=d.getWidth();
int height=d.getHeight();

int w=(int) (.5width);
int h1=(int)(.2


This worked for me.

@Telmo_Cardoso Wanted to know how do you Click on Airplane Mode buttons(Basically interact with the Controls on control center) Are you using Direct co-ordinates(eg. (100,200)) or Giving any locators(eg.Xpath)

Direct coordinates. You are outside your app so you wont be able to interact with objects my querying them in ios

User TouchActions to interact with anything outside your app

1 Like

Ok cool :). Have used the same. Was thinking if there was an option in Appium to switch to the control center ,interact and come back to the app.This would make the code generic across all the devices.(As direct co-ordinates might change across devices)

1 Like

Thanks man! This was really helpful. However, why are you multiplying the height and width by ‘.5’ and ‘.2’ ? Didn’t get hang of that.

He his finding the middle of the width so that the swipe is performed in the center of the phone horizontally and then for the real swipe movement he his going from full height until 20% of height.

1 Like

Dear All,

Let me do my best to help you all…

Use driver.swipe functionality to bring the settings from bottom.
{ now if you wonder on how to find the co- ordinates , then
A. Connect iPad to your device with Appium inspector opened.
B. Swipe up the settings manually .
C. Click on ‘Refresh’ button in Appium Inspector.
4. You may notice “Quick Settings” preview on Appium inspector screen itself.
5. Now choose “Precise Tap” from Appium Inspector and tap over ‘Wifi Icon’ (Green dot will be get marked) , this will also display the “StartX” and “StartY” value.
6. Pass these value as an argument to the drive.tap (method).

Now mode got switched to Offline.

To close the “Settings”, you don’t need to swipe. Instead you may follow the same steps and tap anywhere on page.
// hiding keyboard

int tap_startX= (int) 341.2;
int tap_startY = (int)451.3;
int tap_finger= 1;
int tap_duration=2;
driver.tap(tap_finger, tap_startX , tap_startY , tap_duration );

//swipe up the settings to disable wifi
int swipe_startX= (int) 347.8;
int swipe_startY = (int)1021.4;
int swipe_endx= (int)363.6;
int swipe_endy= (int)800.6;
int swipe_duration =(int) 0.5;
driver.swipe(swipe_startX, swipe_startY, swipe_endx, swipe_endy, swipe_duration);
// disable wifi
int mode_startX= (int) 331.3;
int mode_startY = (int)907.3;
int mode_finger= 1;
int mode_duration=2;
driver.tap(mode_finger, mode_startX , mode_startY , mode_duration );

1 Like

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.

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?


No standard way to do it, however one can emulate the normal user behaviour like it is described in

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?