UI测试中的swift(测试UITableView中的单元格数量)



我对UI测试非常陌生。我的故事板中有一个UITableView,它包含一些单元格。更新:我想断言,当应用程序启动时,UITableView中的单元格数量将超过0。但我不知道如何对这部分进行编码。使用NSPredicate?还是其他人?

 func testCellsNum()
{
        let app = XCUIApplication()
        let tableCell = app.tableRows.count
    //Then what should I do ?
        XCTAssertGreaterThan(tableCell, 0, "should greater than 0")//this line doesn't work

}

如果只有一个表:

func testExample() {
    let app = XCUIApplication()
    let tablesQuery = app.tables
    let count = tablesQuery.cells.count
    XCTAssert(count > 0)
}

如果你有多个表,使用它来获得第一个或任何你想要的索引

 tablesQuery.elementAtIndex(0).cells

相关内容

最新更新