During the execution of my use case, I clicked to jump to a third-party APP, such as AppStore or browser
Then XCUITest has been waiting for the third-party APP to reach the idle state
The test fails because it cannot find the test target program
Why does the test program keep waiting for the third-party APP to reach the idle state, and how to solve it?
The solution I tried: Before each click in the test case, the status of the target APP will be checked, and if it is not in the foreground, it will be pulled back to the foreground. But this method was not executed in the second step above.
The execution log is as follows:
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`
During the execution of my use case, I clicked to jump to a third-party APP, such as AppStore or browser Then XCUITest has been waiting for the third-party APP to reach the idle state The test fails because it cannot find the test target program Why does the test program keep waiting for the third-party APP to reach the idle state, and how to solve it?
The solution I tried: Before each click in the test case, the status of the target APP will be checked, and if it is not in the foreground, it will be pulled back to the foreground. But this method was not executed in the second step above.
The execution log is as follows:
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`