Reputation: 1597
I am using Xcode 7, Swift UI Automation. I need to wait for a UIButton to appear in my home screen. I set an expectation for "exists == 1".
This UIButton sometimes appears, sometime it doesn't. During my UI test, if the element appears, everything is OK. But if the element does not appear, the expectation fails (and I don't want it to fail, I just need to take another flow of action)
How can I make a decision withour the test actually failing?
Upvotes: 3
Views: 855
Reputation: 5149
you have to wait for the expectation and handle it if this doesn't happens do something else into the brackets.
let exists = NSPredicate(format: "exists == 1")
expectationForPredicate(exists, evaluatedWithObject: UIButton, handler: nil)
waitForExpectationsWithTimeout(10) { error in
somethings else
}
Cheers
Upvotes: 1