Skip to content

Commit e957b5f

Browse files
moar
1 parent 96fc6b8 commit e957b5f

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ - (BOOL)fb_isAccessibilityElement
4242
if (nil != attributeValue) {
4343
NSMutableDictionary *updatedValue = [NSMutableDictionary dictionaryWithDictionary:self.additionalAttributes ?: @{}];
4444
[updatedValue setObject:attributeValue forKey:FB_XCAXAIsElementAttribute];
45-
self.additionalAttributes = updatedValue.copy;
45+
self.snapshot.additionalAttributes = updatedValue.copy;
4646
return [attributeValue boolValue];
4747
}
4848

49-
NSLog(@"Cannot determine '%@' accessibility natively: %@. Defaulting to: %@",
49+
NSLog(@"Cannot determine accessibility of '%@' natively: %@. Defaulting to: %@",
5050
self.fb_description, error.description, @(NO));
5151
return NO;
5252
}

WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.m

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,8 @@ - (BOOL)fb_isVisible
3535

3636
@implementation FBXCElementSnapshotWrapper (FBIsVisible)
3737

38-
- (BOOL)fb_hasVisibleAncestorsOrDescendants
38+
- (BOOL)fb_hasVisibleDescendants
3939
{
40-
if (nil != [self fb_parentMatchingOneOfTypes:@[@(XCUIElementTypeAny)]
41-
filter:^BOOL(id<FBXCElementSnapshot> _Nonnull parent) {
42-
return [fetchSnapshotVisibility(parent) boolValue];
43-
}]) {
44-
return YES;
45-
}
4640
for (id<FBXCElementSnapshot> descendant in (self._allDescendants ?: @[])) {
4741
if ([fetchSnapshotVisibility(descendant) boolValue]) {
4842
return YES;
@@ -59,9 +53,9 @@ - (BOOL)fb_isVisible
5953
}
6054

6155
// Fetching the attribute value is expensive.
62-
// Shortcircuit here to save time and assume if any of descendants or ancestors
63-
// are already determined as visible then the container should be visible as well
64-
if ([self fb_hasVisibleAncestorsOrDescendants]) {
56+
// Shortcircuit here to save time and assume if any of descendants
57+
// is already determined as visible then the container should be visible as well
58+
if ([self fb_hasVisibleDescendants]) {
6559
return YES;
6660
}
6761

@@ -72,14 +66,14 @@ - (BOOL)fb_isVisible
7266
if (nil != attributeValue) {
7367
NSMutableDictionary *updatedValue = [NSMutableDictionary dictionaryWithDictionary:self.additionalAttributes ?: @{}];
7468
[updatedValue setObject:attributeValue forKey:FB_XCAXAIsVisibleAttribute];
75-
self.additionalAttributes = updatedValue.copy;
69+
self.snapshot.additionalAttributes = updatedValue.copy;
7670
return [attributeValue boolValue];
7771
}
7872

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

0 commit comments

Comments
 (0)