“UItesting失败:未收到视图2.0s内消失通知”错误

我试图logging一个UItesting用例并运行它,但我遇到了这个错误。 基本上,在我的应用程序中,当我登陆主屏幕时,要求用户允许使用通知和位置。 在我logging这些事件并尝试继续到另一个VC之后,它就像这样正常logging。

[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 

但是当我回放时,它会失败,并在标题中的错误。

2.0s内没有收到视图消息通知

我怀疑,在警报被清除的时候,已经点击了这个button,并且期望家里的VC消失了。 这种理解是正确的吗? 如果是的话,我怎么能推迟期望,如果没有,请帮忙。

系统级警报应该由addUIInterruptionMonitorWithDescription API来处理,这里是来自苹果链接的文档以及swift中的示例代码:

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