【问题标题】:UI Testing NSPredicate for cells staticTextsUI 测试 NSPredicate 的单元格 staticTexts
【发布时间】:2015-08-06 07:00:46
【问题描述】:

我正在创建一个 XCUIElementQuery 以获取所有具有 staticTexts 以字符串开头但不知道的单元格。我用谷歌搜索但没有希望。

绝望的尝试得到 staticText 但不是单元格。

    XCUIElementQuery *rows = [app.cells.staticTexts matchingPredicate:[NSPredicate predicateWithFormat:@"label CONTAINS 'Buy'"]];

有没有人有这方面的经验?我们至少可以得到上述staticTexts中的parent吗?

【问题讨论】:

  • @开发者,你有动态原型单元还是静态单元?
  • 它们是动态原型单元。

标签: objective-c xcode nspredicate xcode-ui-testing ui-testing


【解决方案1】:

我发现这是可行的:

XCUIElementQuery *rows = 
   [app.cells containingPredicate:
        [NSPredicate predicateWithFormat:@"label CONTAINS 'Buy'"]];

如果你使用 app.cells.staticTexts 你会得到一个标签而不是单元格的查询。 还要确保您使用的是官方 Xcode 7。Beta 版可能有问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-07
    • 2017-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多