Search code examples
swift3xctestxcode-ui-testingios-ui-automationxctestcase

How to iterate through ui table elements of different types in swift


Using XCUITest, is there a way to iterate through a subset of a table in swift that contains both 'Cells' and 'Other'? I know I could do table.otherElements or table.cells to get access to each of those separately, but is there a way to get all elements of the table, regardless if type is of cell or other, then iterate over those?

The children and descendants queries require you to specify a type, so using that I would have to specify Other or Cells as well.

I can get access to the table element, but I am looking to iterate through only the first 8 or so elements to verify what is in each other/cell element.

enter image description here


Solution

  • The Type enum provides you with an .any option that will match any element.

    XCUIApplication().tables.children(matching: .any)