我想暂停测试并等待屏幕上出现某个元素,然后再继续。
我没有看到一个好的方法来对此产生期望并等待使用
public func waitForExpectationsWithTimeout(timeout: NSTimeInterval, handler: XCWaitCompletionHandler?)
我一直在使用的创建期望的方法是
public func expectationForPredicate(predicate: NSPredicate, evaluatedWithObject object: AnyObject, handler: XCPredicateExpectationHandler?) -> XCTestExpectation
但这需要一个已经存在的元素,而我想让测试等待一个尚不存在的元素。
有谁知道最好的方法来做到这一点?
In expectationForPredicate(predicate: evaluatedWithObject: handler:)
您没有提供实际的对象,而是提供在视图层次结构中查找它的查询。例如,这是一个有效的测试:
let predicate = NSPredicate(format: "exists == 1")
let query = XCUIApplication().buttons["Button"]
expectationForPredicate(predicate, evaluatedWithObject: query, handler: nil)
waitForExpectationsWithTimeout(3, handler: nil)
查看UI 测试备忘单 https://github.com/joemasilotti/UI-Testing-Cheat-Sheet#waiting-for-an-element-to-appear and 文档 http://masilotti.com/xctest-documentation/Classes/XCTestCase.html#//api/name/expectationForPredicate:evaluatedWithObject:handler:从标头生成(目前没有官方文档),全部由 Joe Masilotti 生成。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)