OGeek|极客世界-中国程序员成长平台

标题: ios - Xcode UI 测试 - 多个 UITableView [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:51
标题: ios - Xcode UI 测试 - 多个 UITableView

如果我们有多个 UITableViews,我们如何在 XCUITests 中指定哪一个?

XCUIApplication().tables.cells.count

返回所有单元格。我们如何选择限制计数的表?



Best Answer-推荐答案


使用可访问性标识符区分您的 TableView 。

class ViewController: UIViewController {
    let firstTableView: UITableView!
    let secondTableView: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()
        firstTableView.accessibilityIdentifier = "First Table"
        secondTableView.accessibilityIdentifier = "Second Table"
    }
}

然后,您可以直接在 UI 测试中引用其中一张表。

XCUIApplication().tables["First Table"].cells.count

关于ios - Xcode UI 测试 - 多个 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36487925/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4