XCTestCase: Wait for app to idle

假装没事ソ 提交于 2019-12-03 00:46:24
Kamil Nomtek.com

Perhaps you have some animation or some other background (or foreground) activity that updates your UI on the main thread frequently. This causes the app to never be "quiesce" - at least on this tab. In our application we had UIView animation with option Repeat. CPU usage was fine and it wasn't a battery drain, but it made the test fail every time. Disabling the animation fixed the issue. I couldn't find a way to force the test not to wait to be idle, so we ended up disabling the animation using #ifdef for the UI test target using runtime arguments as described here: https://stackoverflow.com/a/33466038/168996

let tabBarsQuery = self.app.tabBars
let button = tabBarsQuery.buttons[@"Screen2"]

while writing UI test cases, system taking time to make it hittable so we are creating a predicate for it and waiting for the button.

let predicate = NSPredicate(format: "isHittable == 1") expectation(for: 
predicate, evaluatedWith: button, handler: nil)
waitForExpectations(timeout:10, handler: nil)
button.tap()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!