Best way to turn airplane mode on and off with Calabash

1.5k Views Asked by At

What is the best way to turn airplane mode on and off using calabash-android?

Can I use perform_action('set_preferences', .... ) ??

What does set_preferences do above? I would like to set up android settings during test of application.

Thanks

2

There are 2 best solutions below

2
On BEST ANSWER

Your question is a bit vague. Is it for simulator or device?

In case you just need to disable wifi, you could use

def disable_network
%x(adb shell svc wifi disable)
end


def enable_network
%x(adb shell svc wifi enable)
end

Found here https://azevedorafaela.wordpress.com/tag/disable-wifi-android-simulator-calabash/ I have not tried it myself though.

0
On

For Android devices, we can use this code in Step definition to forget Wi-Fi which is connected:

do

%x(adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings)
%x(adb shell input keyevent 20)
%x(adb shell input keyevent 23)
%x(adb shell input keyevent 20)
%x(adb shell input keyevent 23)

end