我正在编写一个 UIAutomation 测试用例,我需要等待用户被激活才能继续。似乎没有很好的方法来检查按钮是否更改为启用状态。
最好的方法是等待 UI 中发生某些事情,然后再检查它的状态?
dispatch_after 和 NSTimer 似乎都不起作用。他们只是阻止然后失败。
最佳答案
如果您使用 NSPredicates 和期望值,这实际上非常容易。您甚至可以设置超时值。此示例向您展示如何使用 5 秒超时执行此操作。
let exists = NSPredicate(format:"enabled == true")
expectationForPredicate(exists, evaluatedWithObject: app.tables.textFields["MY_FIELD_NAME"], handler: nil)
waitForExpectationsWithTimeout(5, handler: nil)
关于ios - UIAutomation 和 XCTestCase : how to wait for a button to activate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31300372/