UI测试中的swift(测试UITable View中的单元格数)

bea*_*one 4 ios swift uitest

我是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


}
Run Code Online (Sandbox Code Playgroud)

Leo*_*Leo 15

如果你只有一个表:

func testExample() {
    let app = XCUIApplication()
    let tablesQuery = app.tables
    let count = tablesQuery.cells.count
    XCTAssert(count > 0)
}
Run Code Online (Sandbox Code Playgroud)

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

 tablesQuery.elementAtIndex(0).cells
Run Code Online (Sandbox Code Playgroud)