title: UI Testing - wait for dialog then tap Ok button and check controller
body: <p>I am trying to create UI test for my controller. I fill textfields and tap button and now I want to wait for dialog to appear and when it apears I want to tap Ok button and check what controller is shown.</p>
  
  <p>This is end of my test method:</p>
  
  <pre><code>let alert = app.alerts["Error"]
  let exists = NSPredicate(format: "exists == 1")
  self.expectationForPredicate(exists, evaluatedWithObject: alert, handler: nil)
  self.waitForExpectationsWithTimeout(5.0) { (error) in
  
    XCTAssertNil(error, "Something went horribly wrong")
    alert.buttons["Ok"].tap()
    XCTAssertEqual(app.navigationBars.element.identifier, "RegistrationViewController")
  }
  </code></pre>
  
  <p>The problem is that test is evaluated as failure but when I look at phone the dialog appears and Ok button is tapped and controller is also fine.</p>
  
  <p>I get this failure in debug window:</p>
  
  <blockquote>
    <p>UI Testing Failure - No matches found for Alert</p>
  </blockquote>
  
  <p>I guess there is somehow problem with that Tap. How can I fix it? What I am doing wrong? Thanks</p>