《UI 测试失败:2.0s 内没有收到视图确实消失的通知》错误 [英] "UI Testing Failure: Did not receive view did disappear notification within 2.0s" error

查看:30
本文介绍了《UI 测试失败:2.0s 内没有收到视图确实消失的通知》错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试记录一个 UI 测试用例并运行它,但我遇到了这个错误.基本上,在我的应用程序中,当我登陆主屏幕时,会要求用户允许使用通知和位置.在我记录这些事件并尝试转至另一个 VC 后,它通常会像这样记录.

I am trying to record a UI test case and run it back, but I am running into this error. Basically, in my application when I land on the home screen, the user is asked to allow use of notification and location. After I record these events and try to segue to another VC, it records normally like so.

[app.alerts[@"\u201cSampleApp\u201d Would Like to Send You Notifications"].collectionViews.buttons[@"Don\u2019t Allow"] tap];
[app.alerts[@"Allow \u201cSampleApp\u201d to access your location while you use the app?"].collectionViews.buttons[@"Allow"] tap];
//segue to VC2

但是当我播放它时,它失败并显示标题错误.

But when I play it back, it fails with the error in the title.

2.0s内没有收到view确实消失的通知

我怀疑当警报被清除时,segue 按钮已经被点击,虽然它希望家庭 VC 消失,但它没有.这种理解对吗?如果是,我该如何延迟期望,如果不是,请帮助.

I suspect that by the time the alerts are cleared, the segue button is already tapped and while it expects the home VC to disappear, it does not. Is this understanding right?. If yes, how can I delay the expectation, if no, please help.

推荐答案

系统级警报应该由 addUIInterruptionMonitorWithDescription API 处理这里是来自 apple 链接和下面的swift示例代码:

System level alerts should be handled by addUIInterruptionMonitorWithDescription API here is the documentation from apple Link and sample code in swift below:

addUIInterruptionMonitorWithDescription("First Dialog") { (alert) -> Bool in
alert.buttons["Allow"].tap()
return true
}

XCUIApplication().tap()

这篇关于《UI 测试失败:2.0s 内没有收到视图确实消失的通知》错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆