title: Xcode 7 UI Testing: Dismiss Push and Location alerts
body: <p>I encountered a problem with Xcode 7 UI Testing.</p>
  
  <p>The app displays two alerts after my user logs in, the <strong>Request Location</strong> Alert and the <strong>Push Notifications</strong> Alert. Those notifications are shown one right after the other. The Location one appears first.</p>
  
  <p>I try to dismiss them automatically to start my tests.</p>
  
  <p>In order to do that, I add two <em>UIInterruptionMonitor</em>, the first one for the Location Alert and the second one for the Notification Push Alert.</p>
  
  <pre><code>    addUIInterruptionMonitorWithDescription("Location Dialog") { (alert) -&gt; Bool in
          /* Dismiss Location Dialog */
          if alert.collectionViews.buttons["Allow"].exists {
              alert.collectionViews.buttons["Allow"].tap()
              return true
          }
          return false
      }
      addUIInterruptionMonitorWithDescription("Push Dialog") { (alert) -&gt; Bool in
          /* Dismiss Push Dialog */
          if alert.collectionViews.buttons["OK"].exists {
              alert.collectionViews.buttons["OK"].tap()
              return true
          }
          return false
      }
  </code></pre>
  
  <p>But only the Location one is triggered, the handler of Push Notifications <em>UIInterruptionMonitor</em> is never called.</p>
  
  <p>If I return true in the <strong>Request Location</strong> <em>UIInterruptionMonitor</em> as <a href="https://stackoverflow.com/questions/32148965/xcode-7-ui-testing-how-to-dismiss-a-series-of-system-alerts-in-code">this other post accepted answer</a> specifies. Both handler are called but the <em>alert</em> parameter in both <em>UIInterruptionMonitor</em> links to the <strong>Request Location</strong> Alert View so the "OK" button is never found.</p>
  
  <p>How can I dismiss those two successive alerts views?</p>