【发布时间】:2015-11-12 09:13:35
【问题描述】:
我的应用有一个登录屏幕。如果用户在没有在用户名或密码字段中输入任何文本的情况下按下登录按钮,应用程序将显示带有错误消息的UIAlertController。
我正在尝试在 UI 测试中对此逻辑进行建模,并希望断言 UIAlertController 正在显示正确的消息。但是,我找不到 UI 测试访问警报消息属性的方法。下面是测试记录器生成的代码:
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()
}
有什么方法可以提取警报消息的String 值,以便我可以对其进行断言?
【问题讨论】:
标签: ios xcode7 xcode-ui-testing