Reputation: 493
I have upgraded to xcode 7.3 and now my UI tests are breaking. For some reason during the tear down, the app is no longer able to swipe right, but it can do this just before the tear down.
XCUIApplication().swipeRight()
I reverted to xcode 7.2.1 and it works there. Is anyone else experiencing issues like this in xcode 7.3? Any idea how to fix it? Or how to determine if the app reference is stale?
Upvotes: 2
Views: 399
Reputation: 905
I found with Xcode 7.3 that none of the interactions worked in my UI tests. But as suggested, a delay solved my problem.
I added this function to my UITest files:
private func wait(seconds: NSTimeInterval) {
let dateAfterWait = NSDate(timeIntervalSinceNow: seconds)
NSRunLoop.mainRunLoop().runUntilDate(dateAfterWait)
}
And call it before EVERY tap or swipe. A delay of 0.5 seconds worked for me, but I guess that would depend on the complexity of your interface.
I also have a convenience function that waits for an element to appear:
private func waitForElementDisplay(element: XCUIElement) {
let exists = NSPredicate(format: "exists == 1")
expectationForPredicate(exists, evaluatedWithObject: element, handler: nil)
waitForExpectationsWithTimeout(5, handler: nil)
}
but this was not sufficient to allow tapping - I needed to call wait(0.5)
even after this function had returned.
Upvotes: 2