ios - 如何在 UITests 的 `detailTextLabel` 中访问 `tableViewCell`?

标签 ios swift xcode testing xcode-ui-testing

我想检查在我的 UITest 中是否有一个带有给定字符串的 tableViewCell.detailTextLabel。问题是当我搜索 app.tables.cells.children(matching: .staticText) 时,它只会查找 tableViewCell.textLabel 的标签。 关于如何查询 detailTextLabel 有什么想法吗?

最佳答案

您可以尝试更通用的查询来确定文本是否存在。例如,如果您尝试断言某个单元格包含“123 Main St.”,您可以使用以下内容:

let app = XCUIApplication()
XCTAssert(app.staticTexts["123 Main St."]).exists)

当然,如果该文本出现在 textLabel 中,测试仍然会通过。

关于ios - 如何在 UITests 的 `detailTextLabel` 中访问 `tableViewCell`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41966151/

相关文章:

ios - 带有 iOS 7 的 UIImageView 未显示

ios - 如何在核心数据 SWIFT 上保存图像

ios - 无法将类型 'Any' 的值分配给类型 'String?'

ios - 默认今日小部件中的布局约束冲突

objective-c - 如何以编程方式通过 ipad 检测并连接到 3G 网络

ios - Exit() 函数调用未被识别为设备日志中的崩溃

swift - 使用 TextField 自定义 UISearchBar

swift - 如何使用 SwiftUI 拖动工作 slider

ios - 取消请求

ios - 如何从终端配置代码签名身份