1

I'm looking for scenario in calabash which should minimize or background the app and then reopen.

My test procedure is to test something on screen then minimize(which should be run in background)the app and after some seconds it should open it and verify the said contents. As I'm new to Calabash and I know little that "wait/sleep" can be use to wait till existing element/page or any related object but that will just hold my script for some time but I want to minimize and reopen the app which is different than wait. What should be the proper way to through this scenario?

Thanks in advance.

Vaibhav Joshi
  • 211
  • 2
  • 4
  • 9
  • I got my Solution.. Closing this ticket. – Vaibhav Joshi Sep 16 '15 at 10:03
  • Could you share how you were able to do this please? I am working on same issue. – slindsey3000 Sep 23 '15 at 16:33
  • I tried yours answer which you given on http://stackoverflow.com/questions/22393894/calabash-android-how-to-send-app-to-the-background-simulate-device-hardware-ho But I guess there has loop holes. It is not the one exact which I want, here just doing start_test_server_in_background. We can refer below to get the exact one https://rubygems.org/gems/android-adb-extension , I don't know how this will work. for more understanding we can have more discussion on the same. share me your Skype id please. – Vaibhav Joshi Sep 25 '15 at 10:54
  • I believe Calabash 2.0 is going to have what we need. http://calabashapi.xamarin.com/calabash/Calabash/LifeCycle.html#send_current_app_to_background-instance_method – slindsey3000 Sep 25 '15 at 16:37

1 Answers1

0

I am using the following custom commands to background the app and then reopen it.

# THIS FUNCTION WILL TAP THE DEVICE HOME BUTTON PUTTING APP IN BACKGROUND.
Then /^I goto home screen$/ do
    system ("#{default_device.adb_command} shell input keyevent KEYCODE_HOME")
    sleep(1)
end

# RETURN TO APP AFTER LEAVING
Then /^I come back to app$/ do
    start_test_server_in_background
    Timeout.timeout(120) do
        while element_does_not_exist("android.view.View marked:'name'") do
            sleep(1)
        end
    end
    sleep(2)
end
andrewsi
  • 10,807
  • 132
  • 35
  • 51