I am trying to let XCUITest to interact with a remote notification using the below code, but i am curious if this code will click only on my application notification or on any notification received depend on which arrive first?
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let springBoardNotification = springboard.otherElements["NotificationShortLookView"]
let springBoardExists = springBoardNotification.waitForExistence(timeout: 150)
XCTAssert(springBoardExists)
springBoardNotification.tap()
It will click on every notification. To do it, I use this kind of code :
let notification = springboardApp.otherElements.matching(NSPredicate(format: "label BEGINSWITH 'APP_NAME, now,'").firstMatch
where APP_NAME is the exact label appearing at the top left of the notification.
With this, you can also test the exact notification content by adding the expected content after the last comma.