0

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

slindsey3000
  • 4,053
  • 5
  • 36
  • 56

2 Answers2

5

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.

Lasse
  • 1,153
  • 1
  • 10
  • 21
  • How can I get a list of all the settings I can set with ADB? I would like to set up the device with Android settings and run tests. Example : Change the language and run all the tests, Change to Airplane mode and run tests, Change to (insert an Android setting here) .... ? – slindsey3000 Dec 08 '14 at 15:33
  • Good question I have not tried that myself. But you will probably need to use something like "adb shell ..." to do it. So try and search for items related to that. – Lasse Dec 09 '14 at 06:20
2

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

Raj Chinta
  • 93
  • 1
  • 1
  • 6