NotificationShortLookView UI testing with Xcode 12

How can I have access to notification view, when I want to test push notification on iOS simulator with new Xcode.
On Xcode 11 I created springBoard by calling

let springBoard = XCUIApplication(bundleIdentifier: "com.apple.springboard")

and next I had access to notification view with:

springBoard.otherElements["NotificationShortLookView"]

with new Xcode it's not working. How can I still test push notification on simulator with Xcode 12?


It seems like notification elements have a slightly different accessibility hierarchy in iOS 14. This should work:

let springBoard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let notification = springBoard.otherElements["Notification"].descendants(matching: .any)["NotificationShortLookView"]

It's interesting to observe that the actual XCUIElement that represents the push notification has type "BannerNotification" (an XCUIElementType with a rawValue representation 83) which I couldn't find in the public headers. Might be a private type at the moment. Hence the workaround with decendants(matching: .any).
NotificationShortLookView UI testing with Xcode 12
 
 
Q