title: iOS UI Test: how to get message of UIAlertController
body: <p>My app has a login screen. If the user presses the login button without entering any text in either the username or password fields, the app will display a <code>UIAlertController</code> with an error message.</p>
  
  <p>I am trying to model this logic in UI Tests, and want to assert that the <code>UIAlertController</code> is displaying the correct message. However, I can't find a way for the UI Test to access the message property of the alert. Here is the code generated by the test recorder:</p>
  
  <pre><code>func testLoginWithoutPasswort() {
      let app = XCUIApplication()
      let emailTextField = app.textFields["email"]
      emailTextField.tap()
      emailTextField.typeText("xxx@gmail.com")
      app.buttons["Login"].tap()
      app.alerts["Error"].collectionViews.buttons["OK"].tap()
  }
  </code></pre>
  
  <p>Is there any way I can extract the <code>String</code> value of the alert's message, so I can put an assertion on it?</p>