How to find a predicate button under UITests in Xcode7?

I need the following button:

enter image description here

This line works fine:

app.buttons["Reorder 1, $27 000, LondonStreet, ok, Pending"] 

but this is not so:

 app.buttons.elementMatchingPredicate(NSPredicate(format: "accessibilityTitle BEGINSWITH[cd] %@", "Reorder 1")) 
+5
source share
1 answer

When searching for elements through predicates, you must use the XCUIElementAttributes protocol. In this example, I don't think title really works, but try using label (which should display on accessibilityLabel ).

For some reason, the %@ format option doesn't work in Swift. Also note the extra single quotes around "Reorder 1".

 let predicate = NSPredicate(format: "label BEGINSWITH[cd] 'Reorder 1'") let button = app.buttons.elementMatchingPredicate(predicate) 
+9
source

All Articles