5

I am using calabash cucumber to test my iphone app. In my app i am using system level alert dialog for enabling current location. I need to identify whether there is any alert dialogs displayed on the screen. But i am not able to identify the system level alert dialog. I tried below script. but not working.

query("view:'UIAlertView'",:message)
element_exists("alertView child label marked:'#{message}'")

please help me. I need to click on "OK" button in the dialog.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
andro-girl
  • 7,989
  • 22
  • 71
  • 94

1 Answers1

6

I think that by 'system level alert' you mean an alert generated by the OS.

Examples of this kind of alert are 'Some App wants to use your location' and 'Some App wants to send you notifications'.

To interact with these alerts, you must use the uia_* functions and you must allow calabash to launch your app with Instruments.

# check if the alert exists
if uia_query(:alert).count > 0
   # dismiss by touching 'OK'
   uia_tap_mark 'OK'
end
jmoody
  • 2,480
  • 1
  • 16
  • 22
  • This only seems to work with iOS 8, not iOS 7 (Xcode 6.4). The problem seems to come from ui_query which returns a timeout. Any thoughts ? – Macistador Jul 02 '15 at 15:50