I am very new to UI test. I have an UITableView
in my storyboard and it contains some cells.
Update:
I want to assert that the num of cells in UITableView
when the app launches will be more than 0. But I don't know how to code this part.Using NSPredicate
? Or others?
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
}
If you only have one table:
func testExample() {
let app = XCUIApplication()
let tablesQuery = app.tables
let count = tablesQuery.cells.count
XCTAssert(count > 0)
}
If you have multi tables,using this to get first or any index you want
tablesQuery.elementAtIndex(0).cells
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With