In Xcode UI testing, how do I test that staticTexts contains a string?
In the debugger, I can run something like this to print out all the content of staticTexts:
You can use NSPredicate
to filter elements.
let searchText = "the content of the staticText"
let predicate = NSPredicate(format: "label CONTAINS[c] %@", searchText)
let elementQuery = app.staticTexts.containing(predicate)
if elementQuery.count > 0 {
// the element exists
}
With CONTAINS[c]
you specify that the search is case insensitive.
Have a look at Apples Predicate Programming Guide