“UI Testing Failure: Did not receive view did disappear notification within 2.0s” error

假如想象 提交于 2019-12-24 05:59:49

问题


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.

Did not receive view did disappear notification within 2.0s

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.


回答1:


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()


来源:https://stackoverflow.com/questions/39391255/ui-testing-failure-did-not-receive-view-did-disappear-notification-within-2-0s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!