Skip to content

Commit

Permalink
chore: Tune alert detection if system app is active (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Feb 28, 2024
1 parent 878b62a commit 857d3de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ - (BOOL)fb_isSameAppAs:(nullable XCUIApplication *)otherApp
if (nil == otherApp) {
return NO;
}
return [self.bundleID isEqualToString:(NSString *)otherApp.bundleID];
return self == otherApp || [self.bundleID isEqualToString:(NSString *)otherApp.bundleID];
}

@end
7 changes: 6 additions & 1 deletion WebDriverAgentLib/FBAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,12 @@ - (BOOL)clickAlertButton:(NSString *)label error:(NSError **)error
- (XCUIElement *)alertElement
{
if (nil == self.element) {
self.element = XCUIApplication.fb_systemApplication.fb_alertElement ?: self.application.fb_alertElement;
XCUIApplication *systemApp = XCUIApplication.fb_systemApplication;
if ([systemApp fb_isSameAppAs:self.application]) {
self.element = systemApp.fb_alertElement;
} else {
self.element = systemApp.fb_alertElement ?: self.application.fb_alertElement;
}
}
return self.element;
}
Expand Down

0 comments on commit 857d3de

Please sign in to comment.