在 UITest 中,点击登录按钮后,我需要等待两个事件,登录成功后是否显示更新或主屏幕,然后决定要做什么。 文档说,
Only one -waitForExpectationsWithTimeout:handler: can be active at any given time, but * multiple discrete sequences of { expectations -> wait } can be chained together.
所以需要稍微解决一下,但终于想通了。
最佳答案
您可以向谓词添加参数并在条件之间使用 OR。
let skipUpdateButtonPredicate = NSPredicate(format: "%@.exists == 1 OR %@.exists == 1", skipUpdateButton, homeTabBar)
self.expectation(for: skipUpdateButtonPredicate, evaluatedWith: [Any](), handler: nil)
testCase.waitForExpectations(timeout: Constants.loginTimeout,
handler: nil)
然后你可以在这里分支,如果 home 或 update 出现了:
if skipUpdateButton.exists {
skipUpdateButton.tap()
}
关于ios - XCTest waitForExpectations(...) 等待多个结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42957890/