我在我的应用程序中有一个登录屏幕,然后在登录视图被解除后,一个选项卡栏出现。
App本身在所有设备/模拟器中都运行良好。UI测试可以在除iPhone4s以外的所有模拟器中运行。
我认为原因是登录后,登录屏幕消失的时间太长了。所以当我试图访问tabbar时,它抛出了一个异常。
我试过了
let tabBarsQuery = app.tabBars
let predicate = NSPredicate(format: "exists == true")
expectationForPredicate(predicate, evaluatedWithObject: tabBarsQuery, handler: nil)
waitForExpectationsWithTimeout(15, handler: nil) 我得到以下错误
failed: caught "NSUnknownKeyException", "[<XCUIElementQuery 0x7e080d40> valueForUndefinedKey:]: this class is not key value coding-compliant for the key exists."为什么期望不起作用?我该如何解决这个问题?
发布于 2017-03-22 00:18:03
因此,问题似乎在于,无论出于什么原因,XCUIElementQueries的集合都不存在.exists属性。在您的示例中,您不能执行app.tabBars.exists。但是,您可以将谓词更改为:
let predicate = NSPredicate(format: "count > 0")这应该是可行的。
https://stackoverflow.com/questions/34440972
复制相似问题