Xcode 7.3 破坏了 UI 测试 - 拆解后不再正常工作
Xcode 7.3 broke UI tests - not working correctly after teardown anymore
我已经升级到 xcode 7.3,现在我的 UI 测试失败了。由于某种原因,在拆卸过程中,该应用程序不再能够向右滑动,但它可以在拆卸之前做到这一点。
XCUIApplication().swipeRight()
我恢复到 xcode 7.2.1,它在那里工作。 xcode 7.3 中是否还有其他人遇到过此类问题?知道如何解决吗?或者如何确定应用引用是否过时?
我发现 Xcode 7.3 none 的交互在我的 UI 测试中有效。
但正如建议的那样,延迟解决了我的问题。
我将此功能添加到我的UI测试文件中:
private func wait(seconds: NSTimeInterval) {
let dateAfterWait = NSDate(timeIntervalSinceNow: seconds)
NSRunLoop.mainRunLoop().runUntilDate(dateAfterWait)
}
并在每次点击或滑动之前调用它。
0.5 秒的延迟对我有用,但我想这取决于您的界面的复杂性。
我还有一个等待元素出现的便捷函数:
private func waitForElementDisplay(element: XCUIElement) {
let exists = NSPredicate(format: "exists == 1")
expectationForPredicate(exists, evaluatedWithObject: element, handler: nil)
waitForExpectationsWithTimeout(5, handler: nil)
}
但这还不足以允许点击 - 我需要调用 wait(0.5)
即使此函数已返回。
我已经升级到 xcode 7.3,现在我的 UI 测试失败了。由于某种原因,在拆卸过程中,该应用程序不再能够向右滑动,但它可以在拆卸之前做到这一点。
XCUIApplication().swipeRight()
我恢复到 xcode 7.2.1,它在那里工作。 xcode 7.3 中是否还有其他人遇到过此类问题?知道如何解决吗?或者如何确定应用引用是否过时?
我发现 Xcode 7.3 none 的交互在我的 UI 测试中有效。 但正如建议的那样,延迟解决了我的问题。
我将此功能添加到我的UI测试文件中:
private func wait(seconds: NSTimeInterval) {
let dateAfterWait = NSDate(timeIntervalSinceNow: seconds)
NSRunLoop.mainRunLoop().runUntilDate(dateAfterWait)
}
并在每次点击或滑动之前调用它。 0.5 秒的延迟对我有用,但我想这取决于您的界面的复杂性。
我还有一个等待元素出现的便捷函数:
private func waitForElementDisplay(element: XCUIElement) {
let exists = NSPredicate(format: "exists == 1")
expectationForPredicate(exists, evaluatedWithObject: element, handler: nil)
waitForExpectationsWithTimeout(5, handler: nil)
}
但这还不足以允许点击 - 我需要调用 wait(0.5)
即使此函数已返回。