小编Tho*_*EVY的帖子

Xcode 7 UI测试:解除推送和位置警报

我遇到了Xcode 7 UI测试的问题.

我的用户登录后,应用程序会显示两个警报,即请求位置警报和推送通知警报.这些通知一个接一个地显示.位置一出现在第一位.

我尝试自动解雇它们以开始我的测试.

为此,我添加了两个UIInterruptionMonitor,第一个用于Location Alert,第二个用于Notification Push Alert.

    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
    }
Run Code Online (Sandbox Code Playgroud)

但只触发Location 1,从不调用Push Notifications UIInterruptionMonitor的处理程序.

如果我在返回true 请求位置 UIInterruptionMonitor因为这等后接受的答案指定.两个处理程序都被调用,但两个UIInterruptionMonitor中alert参数都链接到请求位置警报视图,因此永远找不到"确定"按钮.

如何解除这两个连续的警报视图?

xcode ios swift xcode-ui-testing

31
推荐指数
2
解决办法
5589
查看次数

标签 统计

ios ×1

swift ×1

xcode ×1

xcode-ui-testing ×1