gpt4 book ai didi

swift - UI 测试失败 - 没有收到 view did disappeared notifications within 2.0s 错误

转载 作者:搜寻专家 更新时间:2023-11-01 05:35:45 24 4
gpt4 key购买 nike

我正在使用 xcode 8 编写我的测试套件 UI 自动化。但是我在尝试关闭警报时一直遇到这个问题。

我目前正在使用 addUIInterruptionMonitor 来关闭我的警报,但是当我使用 app.tap() 调用中断监视器触发时,我收到错误 < strong>UI 测试失败 - 没有收到 view did disappeared notifications within 2.0s error

为什么会发生这种情况,我该如何防止这种情况发生?

附件是我的应用启动代码

 override func setUp() {
super.setUp()
XCUIApplication().terminate()
continueAfterFailure = false
app.launch()

addUIInterruptionMonitorWithDescription("Enable Notifications") { (alert) -> Bool in
let button = alert.buttons["OK"]
if button.exists{
button.tap()
return true
}
return false
}
app.buttons["Enable notifications"].tap()

app.tap()

XCTAssert(app.tabBars.buttons["Settings"].exists)
app.tabBars.buttons["Settings"].tap()
}

最佳答案

首先,在 app.launch() 之前添加监视器,您将不需要 app.tap()

其次,是 app.buttons["Enable notifications"].tap() 触发器,如果​​没有,请删除该行。

第三,如果您在监视器的处理程序上返回 false,系统将点击该警报的“取消”按钮。在这种情况下,我宁愿让测试失败,因为这是一个意外的系统警报。

关于swift - UI 测试失败 - 没有收到 view did disappeared notifications within 2.0s 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40845784/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com