iOS 18 Beta 2 XCTest: Unable to record and play contacts permission system dialog

Unable to record and play the new contacts permission system dialog.

App: https://developer.apple.com/documentation/contacts/accessing-a-person-s-contact-data-using-contacts-and-contactsui

func handleContactsAccessAlert() {
    let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
    let allowButton = springboard.buttons["Allow Full Access"]
    allowButton.tap()
    let access6ContactsButton = springboard.alerts["Allow full access to 6 contacts?"].scrollViews.otherElements.buttons["Allow"]
    access6ContactsButton.tap()
}

 func handleContactsPermissionAlert() {
    let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
    let allowButton = springboard.buttons["Continue"]
    if allowButton.exists {
        allowButton.tap()
        sleep(5)
        handleContactsAccessAlert()
    }
}

func testContactPermissions() {
    let app = XCUIApplication()
    app.launch()
    app.buttons["Request Access"].tap()
    sleep(5)
    handleContactsPermissionAlert()
    sleep(5)
    app.collectionViews/*@START_MENU_TOKEN@*/.staticTexts["Kate Bell"]/*[[".cells.staticTexts[\"Kate Bell\"]",".staticTexts[\"Kate Bell\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
}

Please file a bug report then post the Feedback number here.

It is currently not possible to use UI test recording on apps or processes that you did not author. For instance, it is currently not possible to use UI test recording on SpringBoard or the Settings app. You can try printing the debugDescription of XCUIApplication(bundleIdentifier: "com.apple.springboard") to see what elements are available in that app at that point in time.

I was also stuck on this for ages. The new contacts prompt has a brand new separate process so you need to access its elements through XCUIApplication(bundleIdentifier: "com.apple.ContactsUI.LimitedAccessPromptView")

iOS 18 Beta 2 XCTest: Unable to record and play contacts permission system dialog
 
 
Q