title: Swift UI Test - User Notifications System Alert
body: <p>I'm trying to get past the User Notification system alert by following the flow presented in the follow post, which is the same flow mentioned in the UI testing cheat sheet and a few other posts on SO. </p>
  
  <p><a href="https://stackoverflow.com/questions/31746225/xcode7-xcode-ui-tests-how-to-handle-location-service-alert">Xcode7 | Xcode UI Tests | How to handle location service alert?</a></p>
  
  <p>I'm having a strange problem where I can't hit the OK button. Here is my code</p>
  
  <pre><code>    addUIInterruptionMonitorWithDescription("User Notifications") { (alert) -&gt; Bool in
          let okButton = alert.buttons["OK"]
          let dontAllowButton = alert.buttons["Don\u{2019}t Allow"]
  
          print(okButton.frame)
          print(dontAllowButton.frame)
  
          okButton.tap() // Taps the dontAllowButton ??
  
          return true
      }
  
      launchFinished() // wait for app to load and notification to show
      app.tap()
  </code></pre>
  
  <p>The test successfully goes in the handler after I use <code>app.tap()</code> and the buttons are found and exist, however it can't seem to actually tap the OK button! When I try to tap the OK button it taps the Dont Allow button, and when I try to tap the Dont Allow button, it doesn't tap anything. </p>
  
  <p>The frames of the buttons don't match with what's on screen, either. </p>
  
  <p><a href="https://i.stack.imgur.com/ET2UH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ET2UH.png" alt="User Notification Alert Buttons"></a></p>
  
  <p>When I debug and look at the frames they are:</p>
  
  <p>okButton = (431.5, 377.0, 44.0, 135.0)</p>
  
  <p>dontAllowBtn = (431.5, 512.0, 44.0, 135.0)</p>
  
  <p>Which seems to indicate they have the same X value, and one is on top of the other, which doesn't really make any sense. </p>
  
  <p>Also, I've tried using <code>XCUICoordinate</code> to create some coordinates near the buttons and tap the coordinates instead of the buttons, which is working fine for me in other places in the app, but no coordinate taps seem to register at all. </p>
  
  <p>How do I get past this alert?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I'm on Xcode 7.1.1 and the same problem is occurring with Location Services. It seems it has something to do with Landscape mode that is making it not work. When I create a fresh test app and run the above code it works fine in portrait mode. When I switch it to landscape mode it has the above behavior and does not work.</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>I submitted a bug report to Apple.</p>