UI Test Case XCUIElementTypeQueryProvider tableRows and tableColumns count is 0

324 views Asked by At

I am trying to test whether the UITableView has at least first cell available or not.

func testFirstCellIsAvailable() throws {
    let app = XCUIApplication()
    app.launch()
    let tablesQuery = app.tables
    XCTAssertNotNil(tablesQuery.cells.staticTexts["John"], "First Cell should be John")
            
}

This is one of the simplest way to find the TableView is loaded or not.

However , I see XCUIElementQuery has tableRows and tableColumns, when I check the value it's always zero. So the question is when do we use tableRows and tableColumns

For the above example value of app.tableRows.count and app.tableColumns.count is 0.

enter image description here

1

There are 1 answers

1
Roman Zakharov On BEST ANSWER

tableColumns and tableRows are usually seen in 2D tables, while "flat" UITableView consist of cells. For example, you can see such elements if you create a table in macOS Notes application and inspect XCUIApplication