As of Xcode 7.1 it is possible to register an UI Interuption Handler to handle system alerts, so you call something like this
addUIInterruptionMonitorWithDescription("System Alert") { (alert) -> Bool in
alert.buttons["OK"].tap()
return true
}
and then you interact with the interface ie
.,
tap it.app.tap()
This is all well and good but what if you are presented with a series of notifications one after another ie., location and push notifications alert?
I've tried everything I could think of e.g..
- registering multiple handlers (only the first one gets called, in my case that would be the location dialog)
- returning false in addUIInterruptionMonitoWithDescription -- nothing happens
- tapping the app multiple times to "fire handlers"
- delaying the app taps
- adding handler(s) in the setUp function
- dissming alerts with app.alerts.element.collectionViews.buttons["OK"].tap()
- delaying multiple app.alerts.element.collectionViews.buttons["OK"].tap() //as suggested in this thread https://forums.developer.apple.com/thread/20626
and none of it worked. I just cant get past the second alert.
Similar reports, no working solution yet:
- http://stackoverflow.com/questions/33875301/xcode-7-ui-testing-dismiss-push-and-location-alerts
- http://stackoverflow.com/questions/32148965/xcode-7-ui-testing-how-to-dismiss-a-series-of-system-alerts-in-code?lq=1
- https://forums.developer.apple.com/thread/20626
- https://forums.developer.apple.com/message/47440#47440
How to deal with this problem? Is it a bug or we are not handling it right?
It would be really helpful if someone from Apple comments on this.
Thank you.
Regards