gpt4 book ai didi

ios - 如何在 Xcode 的 UITests 下等待,直到某些 View 可见以供点击?

转载 作者:搜寻专家 更新时间:2023-10-31 08:17:56 24 4
gpt4 key购买 nike

有时,在 Xcode 的 UITests 下,编译器会在加载和显示按钮之前尝试点击按钮。然后出现一个问题,如 no matched found for...

但对此的简单解决方案是:

sleep(1) //wait 1 second and give `mybutton` time to load and be accessible for uitests
mybutton.tap()

但这太可怕了,因为我不能把 0.1 作为参数放在那里。在很多按钮之前等待 1 秒让我很烦。

有没有办法等到它对 uitests 可见?

最佳答案

你应该创建一个 XCTestExpectation并等待它实现

expectationForPredicate(NSPredicate(format: "hittable == true"), evaluatedWithObject: mybutton, handler: nil)
waitForExpectationsWithTimeout(10.0, handler: nil)

mybutton.tap()

关于ios - 如何在 Xcode 的 UITests 下等待,直到某些 View 可见以供点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39788690/

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