gpt4 book ai didi

ios - 在使用 Xcode 进行 UI 测试中,如何控制点击 UIButton 以准备下一步操作后的时间

转载 作者:行者123 更新时间:2023-11-29 00:50:18 25 4
gpt4 key购买 nike

我正在使用 Xcode 7 进行 UI 测试,但遇到一些问题。当我录制 UI 测试时,Xcode 将中文翻译为带有大写“U”的 Unicode,并且显示错误。以及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 中翻译这段代码即可。

干杯

关于ios - 在使用 Xcode 进行 UI 测试中,如何控制点击 UIButton 以准备下一步操作后的时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38187296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com