【发布时间】:2016-02-25 19:27:23
【问题描述】:
我在使用 Xcode 7 UI 测试时遇到了问题。
我的用户登录后,该应用会显示两个警报,请求位置警报和推送通知警报。这些通知一个接一个地显示。位置首先出现。
我尝试自动关闭它们以开始我的测试。
为此,我添加了两个UIInterruptionMonitor,第一个用于位置警报,第二个用于通知推送警报。
addUIInterruptionMonitorWithDescription("Location Dialog") { (alert) -> Bool in
/* Dismiss Location Dialog */
if alert.collectionViews.buttons["Allow"].exists {
alert.collectionViews.buttons["Allow"].tap()
return true
}
return false
}
addUIInterruptionMonitorWithDescription("Push Dialog") { (alert) -> Bool in
/* Dismiss Push Dialog */
if alert.collectionViews.buttons["OK"].exists {
alert.collectionViews.buttons["OK"].tap()
return true
}
return false
}
但只有位置一被触发,推送通知的处理程序UIInterruptionMonitor永远不会被调用。
如果我在 Request Location UIInterruptionMonitor 中返回 true,正如 this other post accepted answer 指定的那样。两个处理程序都被调用,但两个 UIInterruptionMonitor 中的 alert 参数链接到 Request Location 警报视图,因此永远找不到“确定”按钮。
如何关闭这两个连续的警报视图?
【问题讨论】:
-
我正在处理完全相同的问题,但尚未找到解决方案。我尝试只使用一个并在两者中检查“允许”和“确定”,但这也不起作用....
-
我这几天一直在纠结这个问题。你有什么进展吗?太令人沮丧了
-
我也遇到了这个问题。一个警报?没问题。两个连续的警报 => 只有 1 个被点击。
标签: ios xcode swift xcode-ui-testing