gpt4 book ai didi

ios - 在 Xcode UI 测试中等待 30 秒

转载 作者:行者123 更新时间:2023-12-01 18:36:57 24 4
gpt4 key购买 nike

在某一时刻,许多网络服务调用被调用。我只想等 30 秒,因为我知道所有的事情都会在这段时间内完成。我需要第一个粗略的解决方案。

我试过了,但它引发了一些错误:

tablesQuery.buttons["Button"].tap()
DispatchQueue.main.asyncAfter(deadline: .now() + 30.0) {
let tablesQuery2 = tablesQuery

你有什么想法吗?

最佳答案

最简单的方法就是暂时休眠执行:

sleep(30)

但是,如果您希望出现某些内容,最好使用 the built-in function等待存在:

element.waitForExistence(30)

如果什么都没有出现,它不会失败,所以如果它是你逻辑的关键部分,你可能最好通过带有计时器的期望来检查它:

let exists = NSPredicate(format: "exists == %@", true)
expectationForPredicate(exists, evaluatedWithObject: element, handler: nil)
waitForExpectationsWithTimeout(30, handler: nil)

关于ios - 在 Xcode UI 测试中等待 30 秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53160745/

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