XCUITest 等待未经测试的应用程序达到空闲状态
Posted
技术标签:
【中文标题】XCUITest 等待未经测试的应用程序达到空闲状态【英文标题】:XCUITest waits for apps that are not tested to reach idle state 【发布时间】:2021-03-05 09:47:36 【问题描述】:-
在我的用例执行过程中,我点击跳转到第三方APP,比如AppStore或者浏览器
那么XCUITest一直在等待第三方APP进入空闲状态
测试失败,因为找不到测试目标程序
为什么测试程序一直在等待第三方APP进入空闲状态,如何解决?
我尝试的解决方案:在测试用例中每次点击之前,都会检查目标APP的状态,如果不在前台,则将其拉回前台。 但是这个方法在上面的第二步中并没有执行。
执行日志如下:
t = 1871.85s Tap Application 'test app'[0.00, 0.00] -> (297.1, 160.2)
t = 1871.85s Wait for test app to idle
t = 1872.03s Find the Application 'test app'
t = 1872.09s Check for interrupting elements affecting "test app" Application
t = 1872.18s **Wait for com.apple.mobilesafari to idle**
t = 1872.34s **Wait for com.apple.springboard to idle**
t = 1932.47s Requesting snapshot of accessibility hierarchy for app with pid 58
t = 1932.57s Find: Descendants matching predicate identifier == "NotificationShortLookView" OR elementType == 7
t = 1933.59s Retrying `Tap Application 'test app'[0.00, 0.00] -> (297.1, 160.2)` (attempt #2)
t = 1933.59s Wait for test app to idle
t = 1933.76s Find the Application 'test app'
t = 1964.77s Find the Application 'test app' (retry 1)
t = 1995.79s Find the Application 'test app' (retry 2)
t = 2025.80s Collecting extra data to assist test failure triage
t = 2025.81s Requesting snapshot of accessibility hierarchy for app with pid 1899
t = 2025.82s Requesting snapshot of accessibility
hierarchy for app with pid 1899
/Users/zoro/Documents/workspace/zoro_swiftmonkey/zoro_swiftmonkeyUITests/zoro_swiftmonkeyUITests.swift:61: error: -[zoro_swiftmonkeyUITests.zoro_swiftmonkeyUITests testMonkey] : Failed to get matching snapshot: Timed out while evaluating UI query.
t = 2030.37s Tear Down
Test Case '-[zoro_swiftmonkeyUITests.zoro_swiftmonkeyUITests testMonkey]' failed (2030.643 seconds).
Test Suite 'zoro_swiftmonkeyUITests' failed at 2021-03-05 11:25:32.133.
Executed 1 test, with 1 failure (0 unexpected) in 2030.643 (2030.643) seconds
Test Suite 'zoro_swiftmonkeyUITests.xctest' failed at 2021-03-05 11:25:32.133.
Executed 1 test, with 1 failure (0 unexpected) in 2030.643 (2030.644) seconds
Test Suite 'Selected tests' failed at 2021-03-05 11:25:32.134.
Executed 1 test, with 1 failure (0 unexpected) in 2030.643 (2030.645) seconds```
【问题讨论】:
你能分享你的代码吗?很难从日志和描述中追踪您正在尝试做什么以及哪里出了问题。 【参考方案1】:我在这个问题答案列表中找到了解决方案(第二个答案)[1]:Disabling waiting for idle state in UI testing of ios apps
【讨论】:
以上是关于XCUITest 等待未经测试的应用程序达到空闲状态的主要内容,如果未能解决你的问题,请参考以下文章