What app provides system alerts in VisionOS? iOS and iPadOS has springboard app, but VisionOS doesn't

I want to automate tests for my iOS app and start writing UITests. Sometimes system alerts appear, and my tests have to simulate button tapping. In iOS and iPadOS these alerts are available via the system Springboard application:

let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let cancelButton = springboard.alerts.buttons["Cancel"].firstMatch
if cancelButton.exists {
    cancelButton.tap() // <-- cancel button taps, and test continue working
}

But when I launch my test in the Vision Pro simulator, the springboard is not available:

let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
print(springboard.exists) // <-- "false" will be printed, springboard does not exist

It means that I can't automate button tapping in system alerts.


So, my question is:

How can I access system alerts in VisionOS and tap buttons by UITests?

Answered by General Failure in 795088022

I was googling my question and found addUIInterruptionMonitor method:

app.launch()
addUIInterruptionMonitor(withDescription: "System Dialog") { (alert) -> Bool in
    alert.buttons["Allow"].tap()
    return true
}
app.tap()

We only have to enter an appropriate description and the necessary button title.

I was googling my question and found addUIInterruptionMonitor method:

app.launch()
addUIInterruptionMonitor(withDescription: "System Dialog") { (alert) -> Bool in
    alert.buttons["Allow"].tap()
    return true
}
app.tap()

We only have to enter an appropriate description and the necessary button title.

What app provides system alerts in VisionOS? iOS and iPadOS has springboard app, but VisionOS doesn't
 
 
Q