ios - Xcode UI 测试 - UITableView 部分

标签 ios xcode uitableview xcode7 xcode-ui-testing

我想使用 Xcode 的 UI 测试来计算 tableview 中的部分数量以及每个部分中的单元格数量。我该怎么做?

最佳答案

从 Xcode 7 开始, TableView 标题显示为 Other 元素。

这是我在我的应用程序中为(分组的)表格 View 所做的:

extension TableLayoutTests {

    func testHasMessagesGroup() {
        XCTAssert(app.tables.otherElements["MESSAGES"].exists)
    }

    func testHasMessageCell() {
        let header = app.tables.otherElements["MESSAGES"]
        let cell = app.tables.cells.elementBoundByIndex(1)
        XCTAssertGreaterThanOrEqual(cell.accessibilityFrame.minY, header.accessibilityFrame.maxY)
    }

    func testHasOtherMessageCell() {
        let header = app.tables.otherElements["MESSAGES"]
        let cell = app.tables.cells.elementBoundByIndex(2)
        XCTAssertGreaterThanOrEqual(cell.accessibilityFrame.minY, header.accessibilityFrame.maxY)
    }

}

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

相关文章:

ios - 如何区分第一个单元格的索引路径和表末尾空白区域的索引路径?

ios - 如何在 UIImageView 中使用界面构建器上的图像等 pod 资源?

ios - Xcode中的子项目有什么意义?

iphone - 具有分页和来自 NSMutableArray 的数据的动态 UIScrollView

ios - 更改状态栏的前景色

objective-c - Cocos2D拖放 Sprite 问题

ios - React Native - 从 fetch() JSON 渲染多个元素?

ios - 如何在不使用 Storyboard的情况下在 UITableView 中使用静态单元格?

ios - 在 Swift 中运行应用程序时无法保存输入到 UITableView 的文本

ios - 如何配置UITableViewCell以隐藏其控件并显示人字形?