我在我的应用程序中有一个登录屏幕,然后在注销登录视图后,会出现一个选项卡栏。
应用程序本身在所有设备/模拟器中都运行良好。用户界面测试适用于除iphone 4s以外的所有模拟器。
我想原因是登录后,登录屏幕消失的时间太长了。所以当我试图访问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."
为什么期望不起作用?我怎样才能解决这个问题?
最佳答案
因此,这个问题似乎是因为任何原因,对于XCuelEngEnter查询集合来说,不存在.It存在属性。在您的示例中,您不能执行app.tabBars.exists
。但是,您可以将谓词更改为:
let predicate = NSPredicate(format: "count > 0")
这应该管用。
关于ios - iPhone 4s模拟器上的Swift UI测试失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34440972/