【发布时间】:2016-09-07 15:55:21
【问题描述】:
我正在为我的应用编写 UI 测试。我有两个警报,位置和通知。我正在努力寻找解决方案以消除这些警报。
目前我正在使用
systemAlertMonitorToken = addUIInterruptionMonitorWithDescription(systemAlertHandlerDescription) { (alert) -> Bool in
if alert.buttons.matchingIdentifier("OK").count > 0 {
alert.buttons["OK"].tap()
return true
} else {
return false
}
}
和
let notifications = self.app.alerts.element.collectionViews.buttons["OK"]
if notifications.exists {
notifications.tap()
}
但是这两个功能都不允许我关闭警报。
编辑
现在我已经添加了
app.buttons["OK"].tap()
app.tap()
到我的代码,但这意味着我的测试失败了,因为 XCT 会立即寻找“确定”按钮,而不是立即弹出的通知。 我只希望警报 OK 在弹出时被解除,而不是在启动的第一件事上。
【问题讨论】:
标签: ios swift xcode xcode-ui-testing