'UITest keeps failing to tap alert view when running on simulator

I have created a series of UI Tests that run fine on a device but when using a Simulator, I cannot tap alert view buttons.

 let alert = app.alerts["Continue"]
 alert.buttons["Yes"].tap()

Instead, it crashes with

Find: Descendants matching type Button
t =    10.17s     Find: Elements matching predicate '"Yes" IN identifiers'
t =    10.18s     Check for interrupting elements affecting "Yes" Button
t =    10.19s     Requesting snapshot of accessibility hierarchy for app with pid 14120
t =    10.21s     Find: Descendants matching predicate identifier == "NotificationShortLookView" OR elementType == 7
*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil (NSInvalidArgumentException)

I believe (and hope) this is an Xcode 13 bug and may be fixed in an update soon. Does any one know a way around this?



Solution 1:[1]

Turns out this is only an issue when running on an iOS 12 simulator. It is ok when running on an iOS 15.4 simulator.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SirJoeyMichaels