ios - 使用多个谓词进行 Xcode UI 测试

标签 ios xcode xcode7 xcode-ui-testing

Xcode 7 引入了新的 UI 测试工具。我想过滤与多个查询匹配的元素。

例如。包含单元格的表格,每个单元格内有 4 个标签。 我想找到包含的元素。

label 1 text = "A"
label 1 text = "B"
label 1 text = "C"
label 1 text = "D"

框架有 api 可以为其提供一个谓词。 例如。

app.cells.containingPredicate

任何可使用多个谓词进行过滤的内容。或者有什么替代方案可以实现我的要求?

最佳答案

您可以像下面一样链接 containsPredicate 过滤器。

app.cells.containingPredicate(NSPredicate(format: "label BEGINSWITH 'A'")).containingPredicate(NSPredicate(format: "label BEGINSWITH 'B'")).containingPredicate(NSPredicate(format: "label BEGINSWITH 'C'")).containingPredicate(NSPredicate(format: "label BEGINSWITH 'D'"))

这将继续过滤掉您的单元格,直到所有标签都匹配的单元格为止。

关于ios - 使用多个谓词进行 Xcode UI 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34920718/

相关文章:

ios - Xcode 7 更新后 RootViewController 不填充

ios - 如何在单元格 iOS 中为按钮设置标签?

swift - 我在 xcode7 上很快遇到错误。

ios - 主线程上的 Swift UIProgressView,更新属性但不更新 UI

c# - 异常 : Application initializing document picker is missing the iCloud entitlement. 是否设置了 com.apple.developer.icloud-container-identifiers?

ios - UIScrollView 在 iOS 5 中自动滚动随机量

android - Web API 总是返回成功

ios - Xcode 11 更新后看不到应用程序图标的 iMessages 扩展包

iphone - 如何从“表格 View ”单元格中删除白色

app-store-connect - 错误ITMS-90062 : The value for key CFBundleShortVersionString must contain a higher version than that of the previously approved version