如何在 UITests 的 `tableViewCell` 中访问 `detailTextLabel`? [英] How to access the `detailTextLabel` in a `tableViewCell` at UITests?

查看:26
本文介绍了如何在 UITests 的 `tableViewCell` 中访问 `detailTextLabel`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I wanna check whether there is a tableViewCell.detailTextLabel with a given string in my UITest. The problem is when I search for app.tables.cells.children(matching: .staticText) it will only look for labels that are tableViewCell.textLabel. Any ideas on how to query for the detailTextLabel?

推荐答案

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

You can try a more generic query to determine if the text exists at all. If you are trying to assert that a cell contains "123 Main St.", for example, you can use the following:

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

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

Granted, if that text appears in the textLabel the test will still pass.

这篇关于如何在 UITests 的 `tableViewCell` 中访问 `detailTextLabel`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆