title: Xcode 7 UI Testing: how to dismiss a series of system alerts in code
body: <p>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: <code>"MyApp Would Like to Access the Camera"</code> popup and <code>"MyApp Would Like to Send You Notifications"</code> popup. I'd like my test to dismiss both popups.</p>
  
  <p>UI recording generated the following code for me: </p>
  
  <pre><code>[app.alerts[@"cameraAccessTitle"].collectionViews.buttons[@"OK"] tap];
  </code></pre>
  
  <p>However, <code>[app.alerts[@"cameraAccessTitle"] exists]</code> resolves to false, and the code above generates an error: <code>Assertion Failure: UI Testing Failure - Failure getting refresh snapshot Error Domain=XCTestManagerErrorDomain Code=13 "Error copying attributes -25202"</code>. </p>
  
  <p>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. </p>
  
  <p>This question might be related to this SO post which also doesn't have an answer: <a href="https://stackoverflow.com/questions/31746225/xcode7-xcode-ui-tests-how-to-handle-location-service-alert?rq=1">Xcode7 | Xcode UI Tests | How to handle location service alert?</a></p>
  
  <p>Thanks in advance.</p>