在使用 Xcode 测试 UI 中,如何控制点击 UI 按钮准备下一步操作的时间

How can I control the time after an UIButton has been tapped to prepare for next action in UI Testing with Xcode

我正在使用 UI 测试 Xcode 7 但有一些问题。 当我记录 UI 测试时,Xcode 将中文翻译成大写的 Unicode 'U' 并显示错误。 和ui测试代码

XCUIApplication *app = [[XCUIApplication alloc] init];
[app.navigationBars[@"\u5934\u6761"].images[@"new_not_login30"] tap];
XCUIElementQuery *tablesQuery = app.tables;
[tablesQuery.cells.staticTexts[@"\u6211\u7684\u864e\u94b1"] tap];

问题是:点击图像后,有一个动画显示侧边栏和 UITableView 或显示 UIAlertController 但我无法处理持续时间。实际上,在动画中,测试继续寻找下一个要匹配的元素,但这些元素不存在或未生成。所以测试总是失败。 任何解决方案来回答这个问题?请帮我。谢谢

尝试使用 expectationForPredicate。我不知道 objective-c 中的语法。但这里是 swift:

中的一部分代码
let app = XCUIApplication()
app.navigationBars["\u5934\u6761"].images["new_not_login30"].tap()
let label = app.cells.staticTexts["\u6211\u7684\u864e\u94b1"]
let exists = NSPredicate(format: "exists == 1")
expectationForPredicate(exists, evaluatedWithObject: label) {
    // If the label exists, also check that it is enabled
    if label.enabled {
        label.tap()
        return true
    } else {
        return false
    }
}
waitForExpectationsWithTimeout(5) { error in
     if (error != nil) { assertion ....}

}

只需翻译 objective-c 中的这段代码。

干杯