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; }