Skip to content

Commit

Permalink
moar
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach committed Jan 16, 2025
1 parent 96fc6b8 commit e957b5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ - (BOOL)fb_isAccessibilityElement
if (nil != attributeValue) {
NSMutableDictionary *updatedValue = [NSMutableDictionary dictionaryWithDictionary:self.additionalAttributes ?: @{}];
[updatedValue setObject:attributeValue forKey:FB_XCAXAIsElementAttribute];
self.additionalAttributes = updatedValue.copy;
self.snapshot.additionalAttributes = updatedValue.copy;
return [attributeValue boolValue];
}

NSLog(@"Cannot determine '%@' accessibility natively: %@. Defaulting to: %@",
NSLog(@"Cannot determine accessibility of '%@' natively: %@. Defaulting to: %@",
self.fb_description, error.description, @(NO));
return NO;
}
Expand Down
18 changes: 6 additions & 12 deletions WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,8 @@ - (BOOL)fb_isVisible

@implementation FBXCElementSnapshotWrapper (FBIsVisible)

- (BOOL)fb_hasVisibleAncestorsOrDescendants
- (BOOL)fb_hasVisibleDescendants
{
if (nil != [self fb_parentMatchingOneOfTypes:@[@(XCUIElementTypeAny)]
filter:^BOOL(id<FBXCElementSnapshot> _Nonnull parent) {
return [fetchSnapshotVisibility(parent) boolValue];
}]) {
return YES;
}
for (id<FBXCElementSnapshot> descendant in (self._allDescendants ?: @[])) {
if ([fetchSnapshotVisibility(descendant) boolValue]) {
return YES;
Expand All @@ -59,9 +53,9 @@ - (BOOL)fb_isVisible
}

// Fetching the attribute value is expensive.
// Shortcircuit here to save time and assume if any of descendants or ancestors
// are already determined as visible then the container should be visible as well
if ([self fb_hasVisibleAncestorsOrDescendants]) {
// Shortcircuit here to save time and assume if any of descendants
// is already determined as visible then the container should be visible as well
if ([self fb_hasVisibleDescendants]) {
return YES;
}

Expand All @@ -72,14 +66,14 @@ - (BOOL)fb_isVisible
if (nil != attributeValue) {
NSMutableDictionary *updatedValue = [NSMutableDictionary dictionaryWithDictionary:self.additionalAttributes ?: @{}];
[updatedValue setObject:attributeValue forKey:FB_XCAXAIsVisibleAttribute];
self.additionalAttributes = updatedValue.copy;
self.snapshot.additionalAttributes = updatedValue.copy;
return [attributeValue boolValue];
}

// If we fail to fetch the "true" visibility from AX then fallback to
// the lousy `visibleFrame`-based detection method
BOOL fallbackResult = !CGRectIsEmpty(self.fb_visibleFrame);
NSLog(@"Cannot determine '%@' visibility natively: %@. Defaulting to: %@",
NSLog(@"Cannot determine visibility of '%@' natively: %@. Defaulting to: %@",
self.fb_description, error.description, @(fallbackResult));
return fallbackResult;
}
Expand Down

0 comments on commit e957b5f

Please sign in to comment.