有时,在 Xcode 的 UITests 下,编译器会在加载和显示按钮之前尝试点击按钮。然后出现一个问题,如 no matched found for...
。
但对此的简单解决方案是:
sleep(1) //wait 1 second and give `mybutton` time to load and be accessible for uitests
mybutton.tap()
但这太可怕了,因为我不能把 0.1
作为参数放在那里。在很多按钮之前等待 1 秒让我很烦。
有没有办法等到它对 uitests 可见?
最佳答案
你应该创建一个 XCTestExpectation并等待它实现
expectationForPredicate(NSPredicate(format: "hittable == true"), evaluatedWithObject: mybutton, handler: nil)
waitForExpectationsWithTimeout(10.0, handler: nil)
mybutton.tap()
关于ios - 如何在 Xcode 的 UITests 下等待,直到某些 View 可见以供点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39788690/