xcuitest erroneously throws interruption error label: is no longer valid after interruption handling

262 Views Asked by At

I'm trying to run an automation / UI test on a real device but I'm getting an error related to interruption handling. Any idea how to handle this error or how to debug it?

I believe the error is not valid because clearly there is no element (i.e system alerts etc) interrupting the test. I also run a addUIInterruptionMonitor handler but it's never called.

Device: iphone 13 iOS: 13.2 Xcode Version 14.2 (14C18) on MacOS Monterey

Code:

   func testExample() throws {
         
            addUIInterruptionMonitor(withDescription: "test intrerruption"){ (element) -> Bool in
                // this seems to be never called
                print("xxxx intrerruption called")
                return true
            }
           
            // UI tests must launch the application that they test.
            let app = XCUIApplication.init(bundleIdentifier: "com.xpp.exa")
            app.launchEnvironment = ["animations": "0"]
            app.launch()
            let label = "Use phone or email"
            print("xxxx get button by label")
            sleep(3)
            app.buttons[label].firstMatch.tap()
            print("xxxx done ")
            sleep(10)
            app.datePickers.firstMatch.pickerWheels.element(boundBy: 2).adjust(toPickerWheelValue: "1990")
            sleep(10)
            let next = app.buttons["Next"].firstMatch
            print("next isHittable: \(next.isHittable) , isEnabled \(next.isEnabled)")
            XCTAssertTrue(next.waitForExistence(timeout: 5))
            next.tap()
      

Logs:

I'm trying to run an automation / UI test on a real device but I'm getting an error related to interruption handling. Any idea how to handle this error or how to debug it?

I believe the error is not valid because clearly there is no element (i.e system alerts etc) interrupting the test. I also run a addUIInterruptionMonitor handler but it's never called.

Device: iphone 13 iOS: 13.2 Xcode Version 14.2 (14C18) on MacOS Monterey

Logs:

    2023-01-24 13:02:13.882901+0200 xautoUITests-Runner[3585:218724] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)")
    2023-01-24 13:02:13.883267+0200 xautoUITests-Runner[3585:218724] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)")
    2023-01-24 13:02:13.896709+0200 xautoUITests-Runner[3585:218724] Running tests...
    Test Suite 'Selected tests' started at 2023-01-24 13:02:14.035
    Test Suite 'xautoUITests.xctest' started at 2023-01-24 13:02:14.037
    Test Suite 'xautoUITests' started at 2023-01-24 13:02:14.038
    Test Case '-[xautoUITests.xautoUITests testExample]' started.
        t =     0.00s Start Test at 2023-01-24 13:02:14.040
        t =     0.09s Set Up
        t =     0.12s Open com.xpp.exa
        t =     0.18s     Launch com.xpp.exa
        t =     0.18s         Terminate com.xpp.exa:3555
        t =     1.48s         Setting up automation session
    xxxx get button by label
        t =     5.87s Tap "Use phone or email" Button
        t =     5.87s     Find the "Use phone or email" Button
        t =     5.94s     Check for interrupting elements affecting "Use phone or email" Button
        t =    36.71s     Synthesize event
    xxxx done 
        t =    49.85s Set value of PickerWheel to 1990
        t =    49.85s     Find the PickerWheel
        t =    49.90s     Check for interrupting elements affecting "2022" PickerWheel
        t =   137.96s     Synthesize event
        t =   156.47s Find the "Next" Button
        t =   156.53s Find the "Next" Button
    next isHittable: true , isEnabled true
        t =   156.55s Waiting 5.0s for "Next" Button to exist
        t =   157.58s     Checking `Expect predicate `exists == 1` for object "Next" Button`
        t =   157.58s         Checking existence of `"Next" Button`
        t =   157.63s Tap "Next" Button
        t =   157.63s     Find the "Next" Button
        t =   157.65s     Check for interrupting elements affecting "Next" Button
    /Users/xtv/xcod/xauto/xautoUITests/xautoUITests.swift:78: error: -[xautoUITests.xautoUITests testExample] :
 Failed to Error Domain=com.apple.dt.xctest.ui-testing.error Code=10216 
"Targeted element Button, {{32.0, 303.0}, {256.0, 44.0}}, 
label: 'Next' is no longer valid after interruption handling. 
This can happen with UI that auto-dismisses when it loses first-responder status, 
which may occur as part of interruption handling." 
UserInfo={NSLocalizedRecoverySuggestion=A retry-loop around the event may resolve the issue.,
 NSLocalizedDescription=Targeted element Button, {{32.0, 303.0}, {256.0, 44.0}}, 
label: 'Next' is no longer valid after interruption handling. 
This can happen with UI that auto-dismisses when it loses first-responder status, 
which may occur as part of interruption handling.}: Targeted element Button,
 {{32.0, 303.0}, {256.0, 44.0}}, 
label: 'Next' is no longer valid after interruption handling. 
This can happen with UI that auto-dismisses when it loses first-responder status, 
which may occur as part of interruption handling. A retry-loop around the event may resolve the issue.
        t =   247.81s Tear Down
    Test Case '-[xautoUITests.xautoUITests testExample]' failed (248.016 seconds).
    Test Suite 'xautoUITests' failed at 2023-01-24 13:06:22.055.
         Executed 1 test, with 1 failure (0 unexpected) in 248.016 (248.017) seconds
    Test Suite 'xautoUITests.xctest' failed at 2023-01-24 13:06:22.056.
         Executed 1 test, with 1 failure (0 unexpected) in 248.016 (248.019) seconds
    Test Suite 'Selected tests' failed at 2023-01-24 13:06:22.057.
         Executed 1 test, with 1 failure (0 unexpected) in 248.016 (248.022) seconds
0

There are 0 best solutions below