ios - How do I get a fail case to pass in Xcode UITests with swift? -
context: starting automation. unfortunately, practice app has changing ui. e.g., have buttons hidden users, , shown others depending on access permission levels.
goal: want test when fail pass; buttons indeed absent when should be. have overlays , stuff contend too, think can extrapolate button example once i'm shown how it.
before section, login tests have passed. person cannot see sometimeshiddenbutton, need pass fact can't find button, not fail it. how tell that? there special kind of assert can use, or conditionals, or what?
let tablesquery = app.tables app.navigationbars["landingscreen"].buttons["hamburger"].tap() tablesquery.statictexts["alwaysshownbutton"].tap() app.navigationbars["alwaysaccessiblescreen"].buttons["hamburger"].tap() tablesquery.statictexts["sometimeshiddenbutton"].statictexts.tap() <-fails
you can check .exists
value.
if !tablesquery.statictexts["sometimeshiddenbutton"].statictexts.exists { //do users don't need see } else { //do users see button }
Comments
Post a Comment