I am writing UI test cases using the new Xcode 7 UI Testing feature. At some point of my app, I ask the user for permission of camera access and push notification. So two iOS popups will show up: "MyApp Would Like to Access the Camera"
popup and "MyApp Would Like to Send You Notifications"
popup. I'd like my test to dismiss both popups.
UI recording generated the following code for me:
[app.alerts[@"cameraAccessTitle"].collectionViews.buttons[@"OK"] tap];
However, [app.alerts[@"cameraAccessTitle"] exists]
resolves to false, and the code above generates an error: Assertion Failure: UI Testing Failure - Failure getting refresh snapshot Error Domain=XCTestManagerErrorDomain Code=13 "Error copying attributes -25202"
.
So what's the best way of dismissing a stack of system alerts in test? The system popups interrupt my app flow and fail my normal UI test cases immediately. In fact, any recommendations regarding how I can bypass the system alerts so I can resume testing the usual flow are appreciated.
This question might be related to this SO post which also doesn't have an answer: Xcode7 | Xcode UI Tests | How to handle location service alert?
Thanks in advance.
[app.alerts[cameraAccessTitle].collectionViews.buttons[@"OK"] tap];
and[app.alerts[notificationAccessTitle].collectionViews.buttons[@"OK"] tap];
never works. It will dismiss the first popup, then it stops. The second tap doesn't happen. I'll add this detail to my post @ILikeTau – Nalepka