My application has a login screen. If the user presses the login button without entering any text in the username or password fields, the application displays a UIAlert message with an error message.
I am trying to model this logic in user interface tests and want to claim that UIAlert is displaying the correct message. However, I cannot find a way to test the user interface to access the Alert message property. Here is the code generated by the test recorder:
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()
}
Is there anyway I can extract the value of a UIAlert String message, so can I claim to it?
source
share