Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 873
reutsey Avatar asked Jan 27 '26 02:01

reutsey


1 Answers

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

XCUIApplication().tables.children(matching: .any)
like image 61
Titouan de Bailleul Avatar answered Jan 30 '26 00:01

Titouan de Bailleul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!