From 768553e79dd4faac13b35589cf3b5600b3bf3eaa Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 12 Dec 2024 09:11:52 -0800 Subject: [PATCH 1/4] feat: look for critical notification in respectSystemAlerts --- WebDriverAgentLib/Routing/FBSession.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/WebDriverAgentLib/Routing/FBSession.m b/WebDriverAgentLib/Routing/FBSession.m index a4460b4a8..c1cd3cf60 100644 --- a/WebDriverAgentLib/Routing/FBSession.m +++ b/WebDriverAgentLib/Routing/FBSession.m @@ -178,10 +178,13 @@ - (XCUIApplication *)activeApplication if (nil != self.testedApplication) { XCUIApplicationState testedAppState = self.testedApplication.state; if (testedAppState >= XCUIApplicationStateRunningForeground) { - // We look for `SBTransientOverlayWindow` elements for half modals. See https://github.com/appium/WebDriverAgent/pull/946 - NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:@"%K == %@ OR %K == %@", + NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:@"%K == %@ OR %K == %@ OR %K == %@", @"elementType", @(XCUIElementTypeAlert), - @"identifier", @"SBTransientOverlayWindow"]; + // To ook for `SBTransientOverlayWindow` elements. See https://github.com/appium/WebDriverAgent/pull/946 + @"identifier", @"SBTransientOverlayWindow", + // To look for 'criticalAlertSetting' elements https://developer.apple.com/documentation/usernotifications/unnotificationsettings/criticalalertsetting + // See https://github.com/appium/appium/issues/20835 + @"identifier", @"Notification"]; if ([FBConfiguration shouldRespectSystemAlerts] && [[XCUIApplication.fb_systemApplication descendantsMatchingType:XCUIElementTypeAny] matchingPredicate:searchPredicate].count > 0) { From e142b2f3f4a4be889c2f58a7594c5e6b3f5c6864 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 12 Dec 2024 09:28:50 -0800 Subject: [PATCH 2/4] use IN --- WebDriverAgentLib/Routing/FBSession.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/WebDriverAgentLib/Routing/FBSession.m b/WebDriverAgentLib/Routing/FBSession.m index c1cd3cf60..5797046cb 100644 --- a/WebDriverAgentLib/Routing/FBSession.m +++ b/WebDriverAgentLib/Routing/FBSession.m @@ -178,13 +178,13 @@ - (XCUIApplication *)activeApplication if (nil != self.testedApplication) { XCUIApplicationState testedAppState = self.testedApplication.state; if (testedAppState >= XCUIApplicationStateRunningForeground) { - NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:@"%K == %@ OR %K == %@ OR %K == %@", + NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:@"%K == %@ OR identifier IN {%@, %@}", @"elementType", @(XCUIElementTypeAlert), - // To ook for `SBTransientOverlayWindow` elements. See https://github.com/appium/WebDriverAgent/pull/946 - @"identifier", @"SBTransientOverlayWindow", + // To look for `SBTransientOverlayWindow` elements. See https://github.com/appium/WebDriverAgent/pull/946 + @"SBTransientOverlayWindow", // To look for 'criticalAlertSetting' elements https://developer.apple.com/documentation/usernotifications/unnotificationsettings/criticalalertsetting // See https://github.com/appium/appium/issues/20835 - @"identifier", @"Notification"]; + @"Notification"]; if ([FBConfiguration shouldRespectSystemAlerts] && [[XCUIApplication.fb_systemApplication descendantsMatchingType:XCUIElementTypeAny] matchingPredicate:searchPredicate].count > 0) { From 3c0e22f4df8fe79ab36e7b53f75beb5f21707915 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 12 Dec 2024 10:33:56 -0800 Subject: [PATCH 3/4] Update FBSession.m --- WebDriverAgentLib/Routing/FBSession.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WebDriverAgentLib/Routing/FBSession.m b/WebDriverAgentLib/Routing/FBSession.m index 5797046cb..629980ef7 100644 --- a/WebDriverAgentLib/Routing/FBSession.m +++ b/WebDriverAgentLib/Routing/FBSession.m @@ -178,10 +178,10 @@ - (XCUIApplication *)activeApplication if (nil != self.testedApplication) { XCUIApplicationState testedAppState = self.testedApplication.state; if (testedAppState >= XCUIApplicationStateRunningForeground) { - NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:@"%K == %@ OR identifier IN {%@, %@}", + NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:@"%K == %@ OR %K IN {%@, %@}", @"elementType", @(XCUIElementTypeAlert), // To look for `SBTransientOverlayWindow` elements. See https://github.com/appium/WebDriverAgent/pull/946 - @"SBTransientOverlayWindow", + @"identifier", @"SBTransientOverlayWindow", // To look for 'criticalAlertSetting' elements https://developer.apple.com/documentation/usernotifications/unnotificationsettings/criticalalertsetting // See https://github.com/appium/appium/issues/20835 @"Notification"]; From 5d048e36da58d1ae79308260ee1eaa9b20708b3a Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Fri, 13 Dec 2024 09:20:39 -0800 Subject: [PATCH 4/4] Use NotificationShortLookView instead as identifier --- WebDriverAgentLib/Routing/FBSession.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebDriverAgentLib/Routing/FBSession.m b/WebDriverAgentLib/Routing/FBSession.m index 629980ef7..e8fb95a18 100644 --- a/WebDriverAgentLib/Routing/FBSession.m +++ b/WebDriverAgentLib/Routing/FBSession.m @@ -184,7 +184,7 @@ - (XCUIApplication *)activeApplication @"identifier", @"SBTransientOverlayWindow", // To look for 'criticalAlertSetting' elements https://developer.apple.com/documentation/usernotifications/unnotificationsettings/criticalalertsetting // See https://github.com/appium/appium/issues/20835 - @"Notification"]; + @"NotificationShortLookView"]; if ([FBConfiguration shouldRespectSystemAlerts] && [[XCUIApplication.fb_systemApplication descendantsMatchingType:XCUIElementTypeAny] matchingPredicate:searchPredicate].count > 0) {