Post

Replies

Boosts

Views

Activity

How to detect Push Notification in UITest (Xcode 14.2)
I want to implement a UITest that detect push notifications sent from my server. I started with a simple test and I am triggering Push Notification with xcrun simctl push    func testPushNotification() {     app.launch() //launching app     sleep(1) // waiting for app to setup     // Launch springboard     springboard.activate() // Here I am triggering PN with xcrun and it appears on screen     let notification = springboard.otherElements["Notification"].descendants(matching: .any)["NotificationShortLookView"]     XCTAssertTrue(notification.waitForExistence(timeout: 5))     notification.tap()   } so the test flow goes like: app launches springboard is activated and app goes background PN is triggered with xcrun and appears on the Simulator's screen I can see PN in springboard's view hierarchy: Window (Main), 0x12e533bd0, {{0.0, 0.0}, {390.0, 844.0}} Other, 0x12e533ce0, {{0.0, 0.0}, {390.0, 844.0}} BannerNotification, 0x12e533df0, {{8.0, 40.0}, {374.0, 79.3}} Other, 0x12e533f00, {{8.0, 40.0}, {374.0, 79.3}}, label: 'Powiadomienie' Other, 0x12e52e460, {{8.0, 40.0}, {374.0, 79.3}} BannerNotification, 0x12e52e570, {{8.0, 40.0}, {374.0, 79.3}}, identifier: 'NotificationShortLookView', label: ' App, teraz, Push Notification Test, Hey! 👋, Is this working?' but unfortunately my test is not able to detect the Push notification. I tried to look for that notification in 20 different ways, find it by text etc. but unfortunately nothing works. Any ideas?
0
1
780
Dec ’22