Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode UI Testing with multiple predicates

Xcode 7 introduces new UI Testing tools. I want to filter an element that matching more than one query.

For instance. A table with cells that each cell has 4 labels inside them. I want to find element that contain.

label 1 text = "A"
label 1 text = "B"
label 1 text = "C"
label 1 text = "D"

Framework has api to give it one predicate. For example.

app.cells.containingPredicate

Anything available to filter using more than one predicate. Or any alternative to achieve my requirement?

like image 986
Swift Hipster Avatar asked Aug 29 '26 03:08

Swift Hipster


1 Answers

You can chain containingPredicate filters like below.

app.cells.containingPredicate(NSPredicate(format: "label BEGINSWITH 'A'")).containingPredicate(NSPredicate(format: "label BEGINSWITH 'B'")).containingPredicate(NSPredicate(format: "label BEGINSWITH 'C'")).containingPredicate(NSPredicate(format: "label BEGINSWITH 'D'"))

This will keep filtering out your cells until a cell with all for labels match.

like image 131
MadNik Avatar answered Aug 30 '26 18:08

MadNik