xcode - XC UITesting with Dynamic Labels -
i'm trying assert value of label (which populated dynamically) contains substring part of result of uitest.
my issue xctassert doesn't seem allow substrings or approximate matches (from can find anyway). have advice on how might write following find match "hours ago" instead of specific "xx hours ago"?
at present i'm able work exact matches (as below).
//set expectation let texttofind = app.statictexts["13 hours ago"] let exists = nspredicate(format: "exists == true") expectationforpredicate(exists, evaluatedwithobject: texttofind, handler: nil) //give app time network data & update ui waitforexpectationswithtimeout(5, handler: nil) //assert results xctassert(texttofind.exists)
change query finds ui element method other name. ui test recording feature in xcode can work through — see wwdc2015 session introducing ui testing example of doing this.
once you've found ui element without using name, expectation test can use predicate tests name substring.
or:
- explicitly use query find
app's subelement matching predicate (seeelementmatchingpredicateinxcuielementquery) rather subscripting, can useexiststest verify it's there. again, see wwdc session examples.
Comments
Post a Comment