Not able to find user generated alerts in XCTest on Ventura

This is for MacOS My app posts errors during its operation. Two years ago the following used to be able to test whether the alert was correct (or missing)

  func isRightAlert(alertImgStr: String, target: String) -> Bool{  
    let app = XCUIApplication()
    let ackdialog = app.dialogs["alert"]
    let imageexists = ackdialog.images[alertImgStr/*"CaptureEclipse alert"*/].exists
    //let full = app.debugDescription
    XCTAssert(imageexists)
    let acklist = ackdialog.children(matching: .staticText)
    //NSLog( String(acklist.count))
    var found = false
    NSLog("Alert>>>>>>>>>>>")
    for index in 0...acklist.count - 1{
       <see if is is one of the expected ones>
        
    }
    <other tests>
}

Now that I am on Ventura with XCode 14.3 it is no longer able to detect the alert. ackdialog returns as not found. imageexists is false which triggers the Assert The alert is on the screen when the timeouts I added trigger

app.debugDescription justs lists all of my menu entries

These are my own alerts (NSAlert) and not system alerts.

Hello! If the item does not appear in the XCUIApplication's debug description, then it is either not present according to Accessibility or it is a system dialog. Have you tried checking for app.alerts?

It would also be helpful to file a Feedback Assistant post with the result bundle of your test run attached, so we can take a look. Thanks!

I used the Accessibility tool and the alert shows

This worked fine when I ran the test under Catalina/Big Sur

It is not a system dialog. It is one that my app posts when a scenario condition is not met.

I am not sure what you are asking WRT the bundle of the test run.

The code I am currently using does the search as

 found = app.alerts.firstMatch.waitForExistence(timeout: 5.0)
    let ackdialog = app.alerts.firstMatch

I have also tried posting the dialog using beginSheetModal and then searching for a sheet.

this is what Xcode sees

The alert is actually queued for display while the Total Eclipse Editor dialog is being created and then displayed once that window appears when it is legal to post alerts. In other words it appears immediately, but I added the fudge of waiting since I am now running on a Studio instead of a Mac Pro 2013. The "Save Prefs" button is the previous configuration dialog.

I tested it again this morning using the original test code from above. It now works on both M1/Ventura and Intel/Monterey.

To adapt to Ventura I briefly switched the dialogs from modal to sheets. I then went back to modal dialogs issued more cleverly. I thought I had used the original test code for both before I changed the test design. Mea Culpa

This thread can be closed (and deleted)

Accessibility Inspector does not always report the same Accessibility hierarchy as XCTest. You can use an Accessibility Audit to see if there are any discrepancies preventing your elements from being seen by XCTest.

Not able to find user generated alerts in XCTest on Ventura
 
 
Q