Dismissing system alerts during UI testing only works for the first alert
| Originator: | janine.sisk | ||
| Number: | rdar://25120034 | Date Originated: | 3-11-2016 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | iOS 9.2 (13C75) |
| Classification: | Serious Bug | Reproducible: | Always |
Description:
When doing UI testing on an app which uses two entitlements that require user permission, say location and notifications, it is not possible to dismiss the second and subsequent alerts.
Steps to Reproduce:
I have a sample app but it fails to upload every time I attach it. I will attempt to add it as an edit after I submit this report, but if there is still no attachment when you receive it, please contact me at <redacted> and I will send it to you.
I have used addUIInterruptionMonitorWithDescription to implement monitors which are supposed to fire when an alert dialog is displayed.
Expected Results:
The interruption monitor functions should be run for each alert that is presented.
Actual Results:
The first alert is dismissed correctly by the appropriate interruption monitor; all of them are run. The second one is left open even after the test is done and the app has exited, because the interruption monitors do not run a second time.
The UI test, which does nothing but tap a button (this is necessary for the interruption monitors to run at all), exits with this error:
UI Test Activity:
Assertion Failure: UI Testing Failure - No matches found for "Allow “UITestSample” to access your location even when you are not using the app?" Alert
Query input was {(
Alert 0x7fb33a85f210: traits: 72057602627862528, {{52.5, 242.5}, {270.0, 182.0}}, label: '“UITestSample” Would Like to Send You Notifications'
)}
(note that nowhere in my code am I telling it to look for either of these alerts by label. The first alert to show, which is properly dismissed, is the one about location. The second one, which is not dismissed, is the one about notifications.)
Additional Notes:
This may go without saying, but you do need to delete the app completely from the simulator before each run in order to see the full behavior.
This problem is not unique to my code; there are reports of it all over the place, and no solutions.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Hi janine.sisk,
I noticed the same problem since i have 3 permissions that pop-up at setup of the app. From what I saw the problem is that the framework looks for an Allow button, but not all permissions have an Allow and Don't Allow setup. For example, for location permission it is like this, but for Motion&Fitness you have the options Ok and Don't Allow. And now, for my app at least, the location pop-up has 3 options on iOS11. I will raise as well a radar on this issue and hopefully something will change.