From 54f91f198e45535ea9d86b7eee40b21f43f84294 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Wed, 21 Feb 2024 18:21:16 +0100 Subject: [PATCH] chore: Simplify the logic of alert element detection (#851) --- WebDriverAgentLib/FBAlert.m | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/WebDriverAgentLib/FBAlert.m b/WebDriverAgentLib/FBAlert.m index 0709e5f1f..cd71663dd 100644 --- a/WebDriverAgentLib/FBAlert.m +++ b/WebDriverAgentLib/FBAlert.m @@ -261,16 +261,7 @@ - (BOOL)clickAlertButton:(NSString *)label error:(NSError **)error - (XCUIElement *)alertElement { if (nil == self.element) { - self.element = self.application.fb_alertElement; - if (nil == self.element) { - XCUIApplication *systemApp = XCUIApplication.fb_systemApplication; - for (XCUIApplication *activeApp in XCUIApplication.fb_activeApplications) { - if (systemApp.processID == activeApp.processID) { - self.element = activeApp.fb_alertElement; - break; - } - } - } + self.element = XCUIApplication.fb_systemApplication.fb_alertElement ?: self.application.fb_alertElement; } return self.element; }