Best way to turn airplane mode on and off with Calabash

后端 未结 2 779
终归单人心
终归单人心 2021-01-28 18:31

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_

相关标签:
2条回答
  • 2021-01-28 18:52

    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

    0 讨论(0)
  • 2021-01-28 19:01

    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 讨论(0)
提交回复
热议问题