RUBY[IOS]Can we toggle flight mode in IOS

I was trying to turn the flight mode on and off on real device iPhone 8.0

pry(main)> toggle_airplane_mode
post /appium/device/toggle_airplane_mode
Selenium::WebDriver::Error::UnknownError: Not yet implemented. Please help us: http://appium.io/get-involved.html
from /Users/gireesha/.rvm/gems/ruby-2.1.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/response.rb:52:in `assert_ok’

@bootstraponline is this not implemented on ruby lib

It has nothing to do with ruby lib. Ruby lib calls the implementation normally, but its not implemented in appium ios controller:

iOSController.toggleFlightMode = function (cb) {
  cb(new NotYetImplementedError(), null);
};

I imagine it should be because of iOS restrictions.

It is something you really need for your tests?

@Telmo_Cardoso Yah i really to need this for ma tests, as i have non functional tests cases as well.

Well… this is not very good but :smile:

You can go to General → Accessibility and activate the AssistiveTouch. Then place that icon where it wont break anything on your tests.

Now when you need to enable flight mode your tests will be something like:

  • One tap on the AssistiveTouch icon
  • One tap on the Home button of AssistiveTouch icon
  • Tap on Settings
  • Tap on Airplane Mode switch in order to enable/disable it

Its not good I know, but its the only way I found to make some magic happen :wink: and mess around settings, etc.

Use the TouchAction class for the taps, swipes, scrolls, etc.

@Telmo_Cardoso Thanks a lot

How to get this done from appium, i have Assistive touch on ma screen, how do i touch them from appium though inspector i can’t see the properties

toggle_airplane_mode is currently available on Android only. As pointed out, this is a server limitation and not Ruby specific. I recommend opening an enhancement request on GitHub if one doesn’t already exist.

If you can’t see the elements (iOS doesn’t allow automating system Settings) then you may have to fallback to either relative coordinates or image recognition (this is an exercise left to the reader).

Direct coordinates. Like I told you, its far from a perfect solution.

@Telmo_Cardoso Thanks mate… Got it worked by swiping the the control center and then accessing the flight mode from there …

yeah, way simpler :slight_smile: I just need other settings changed :smiley: thats why I use this way…

@saikrishna321 : How did you swipe the control center? For some reason, I am not able to do the same. Can you share the code?

@saikrishna321, I’m facing same issue,cannot select airplane mode option. i’m using java, can you please share the code on how to select the airplane mode or wifi enable/disable.

Thanks in advance

on ruby I use %, so I can swipe from 99,9% of height. In java I think it just accepts direct coordinates, so you probably have to get the height and then use that value to swipe up. Just an idea, because I never tested in java.

It doesn’t work in java. When I try to swipe from bottom most position, it just scrolls in the app. Since java take ‘int’ co-ordinates, if I increase the size by even 1, it says not found and exits. I guess we can not pull the control bar using java.

It just worked for me in iPhone 5s by using
driver.swipe(0,557,0,250,800);

And able to click on Wifi button using
driver.tap(1,90,185,800);
for airplane mode:
driver.tap(1,20,185,800);

It just a work around…

1 Like

Thanks @mervin_dinesh. I will try the work around. Do let me know if you find something similar for iPhone 4S as well. Somehow it’s not working there.

Hey Guys, Ul can use this code:

I am trying this pulling up the control center using swipe on java …but no luck…?