From a36c190cbb0c3d83cd9efa386d8bea2b5ce5fdb8 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Wed, 15 Jan 2025 20:50:20 +0100 Subject: [PATCH] Remove custom stuff for good --- .../FBXCElementSnapshotWrapper+Helpers.h | 9 ++- .../FBXCElementSnapshotWrapper+Helpers.m | 19 ++++- .../Categories/XCUIApplication+FBHelpers.m | 19 +---- .../Categories/XCUIElement+FBAccessibility.m | 19 +++-- .../Categories/XCUIElement+FBIsVisible.m | 50 +++++++++--- .../Categories/XCUIElement+FBUtilities.h | 32 -------- .../Categories/XCUIElement+FBUtilities.m | 76 ------------------- .../XCUIElement+FBWebDriverAttributes.m | 21 +---- .../Utilities/FBXCAXClientProxy.h | 7 +- .../Utilities/FBXCAXClientProxy.m | 14 ++-- WebDriverAgentLib/Utilities/FBXPath.m | 9 +-- .../Utilities/XCTestPrivateSymbols.h | 3 + .../Utilities/XCTestPrivateSymbols.m | 1 + .../IntegrationTests/FBElementSwipingTests.m | 2 +- .../FBXPathIntegrationTests.m | 2 +- .../Doubles/XCElementSnapshotDouble.m | 5 ++ 16 files changed, 102 insertions(+), 186 deletions(-) diff --git a/WebDriverAgentLib/Categories/FBXCElementSnapshotWrapper+Helpers.h b/WebDriverAgentLib/Categories/FBXCElementSnapshotWrapper+Helpers.h index 4ce84f88b..075f70d92 100644 --- a/WebDriverAgentLib/Categories/FBXCElementSnapshotWrapper+Helpers.h +++ b/WebDriverAgentLib/Categories/FBXCElementSnapshotWrapper+Helpers.h @@ -58,9 +58,14 @@ NS_ASSUME_NONNULL_BEGIN @param attribute attribute's accessibility identifier. Can be one of `XC_kAXXCAttribute`-prefixed attribute names. - @return value for given accessibility property identifier + @param timeout The maximum time is flota seconds to wait until XCTest/Accessbility framework + returns the value of the requested attribute + @param error Error instance in case of a failure + @return value for given accessibility property identifier or nil in case of failure */ -- (nullable id)fb_attributeValue:(NSString *)attribute; +- (nullable id)fb_attributeValue:(NSString *)attribute + timeout:(NSTimeInterval)timeout + error:(NSError **)error; /** Method used to determine whether given element matches receiver by comparing it's parameters except frame. diff --git a/WebDriverAgentLib/Categories/FBXCElementSnapshotWrapper+Helpers.m b/WebDriverAgentLib/Categories/FBXCElementSnapshotWrapper+Helpers.m index c16a1a848..78e6a0275 100644 --- a/WebDriverAgentLib/Categories/FBXCElementSnapshotWrapper+Helpers.m +++ b/WebDriverAgentLib/Categories/FBXCElementSnapshotWrapper+Helpers.m @@ -20,6 +20,8 @@ #import "XCUIElement+FBWebDriverAttributes.h" #import "XCUIHitPointResult.h" +#define VisibleFrameFetchTimeout 0.3 + inline static BOOL isSnapshotTypeAmongstGivenTypes(id snapshot, NSArray *types); @@ -65,10 +67,17 @@ - (NSString *)fb_description } - (id)fb_attributeValue:(NSString *)attribute + timeout:(NSTimeInterval)timeout + error:(NSError **)error { + BOOL isTimeoutSet = [FBXCAXClientProxy.sharedClient setAXTimeout:timeout error:nil]; NSDictionary *result = [FBXCAXClientProxy.sharedClient attributesForElement:[self accessibilityElement] - attributes:@[attribute]]; - return result[attribute]; + attributes:@[attribute] + error:error]; + if (isTimeoutSet) { + [FBXCAXClientProxy.sharedClient setAXTimeout:FBDefaultAxTimeout error:nil]; + } + return [result objectForKey:attribute]; } inline static BOOL areValuesEqual(id value1, id value2); @@ -146,8 +155,10 @@ - (CGRect)fb_visibleFrameWithFallback if (!CGRectIsEmpty(thisVisibleFrame)) { return thisVisibleFrame; } - - NSDictionary *visibleFrameDict = (NSDictionary*)[self fb_attributeValue:@"XC_kAXXCAttributeVisibleFrame"]; + + NSDictionary *visibleFrameDict = [self fb_attributeValue:FB_XCAXAVisibleFrameAttributeName + timeout:VisibleFrameFetchTimeout + error:nil]; if (visibleFrameDict == nil) { return thisVisibleFrame; } diff --git a/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m b/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m index 26cc4c914..03d4407f2 100644 --- a/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +++ b/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m @@ -176,22 +176,7 @@ - (NSDictionary *)fb_tree - (NSDictionary *)fb_tree:(nullable NSSet *)excludedAttributes { - // This set includes XCTest-specific internal attribute names, - // while the `excludedAttributes` arg contains human-readable ones - NSMutableSet* includedAttributeNames = [NSMutableSet setWithArray:FBCustomAttributeNames()]; - if (nil != excludedAttributes) { - for (NSString *attr in excludedAttributes) { - NSString *mappedName = [customExclusionAttributesMap() objectForKey:attr]; - if (nil != mappedName) { - [includedAttributeNames removeObject:attr]; - } - } - } - id snapshot = nil == excludedAttributes - ? [self fb_snapshotWithAllAttributes:YES] - : [self fb_snapshotWithCustomAttributes:[includedAttributeNames allObjects] - exludingStandardAttributes:NO - inDepth:YES]; + id snapshot = [self fb_takeSnapshot:YES]; return [self.class dictionaryForElement:snapshot recursive:YES excludedAttributes:excludedAttributes]; @@ -199,7 +184,7 @@ - (NSDictionary *)fb_tree:(nullable NSSet *)excludedAttributes - (NSDictionary *)fb_accessibilityTree { - id snapshot = [self fb_snapshotWithAllAttributes:YES]; + id snapshot = [self fb_takeSnapshot:YES]; return [self.class accessibilityInfoForElement:snapshot]; } diff --git a/WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.m b/WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.m index a1416c1c8..f75219f2d 100644 --- a/WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.m +++ b/WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.m @@ -14,13 +14,13 @@ #import "XCUIElement+FBUtilities.h" #import "FBXCElementSnapshotWrapper+Helpers.h" +#define AX_FETCH_TIMEOUT 0.3 + @implementation XCUIElement (FBAccessibility) - (BOOL)fb_isAccessibilityElement { - id snapshot = [self fb_snapshotWithCustomAttributes:@[FB_XCAXAIsElementAttributeName] - exludingStandardAttributes:YES - inDepth:NO]; + id snapshot = [self fb_takeSnapshot:NO]; return [FBXCElementSnapshotWrapper ensureWrapped:snapshot].fb_isAccessibilityElement; } @@ -34,8 +34,17 @@ - (BOOL)fb_isAccessibilityElement if (nil != isAccessibilityElement) { return isAccessibilityElement.boolValue; } - - return [(NSNumber *)[self fb_attributeValue:FB_XCAXAIsElementAttributeName] boolValue]; + + NSError *error = nil; + NSNumber *attributeValue = [self fb_attributeValue:FB_XCAXAIsElementAttributeName + timeout:AX_FETCH_TIMEOUT + error:&error]; + if (nil != attributeValue && nil == error) { + return [attributeValue boolValue]; + } + + NSLog(@"Cannot determine element accessibility: %@", error.description); + return NO; } @end diff --git a/WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.m b/WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.m index 7e372415d..bc1136c5d 100644 --- a/WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.m +++ b/WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.m @@ -9,25 +9,24 @@ #import "XCUIElement+FBIsVisible.h" -#import "FBConfiguration.h" #import "FBElementUtils.h" -#import "FBMathUtils.h" -#import "FBActiveAppDetectionPoint.h" -#import "FBSession.h" -#import "FBXCAccessibilityElement.h" #import "FBXCodeCompatibility.h" #import "FBXCElementSnapshotWrapper+Helpers.h" #import "XCUIElement+FBUtilities.h" -#import "XCUIElement+FBUID.h" #import "XCTestPrivateSymbols.h" +#define AX_FETCH_TIMEOUT 0.3 + +NSNumber* _Nullable fetchSnapshotVisibility(id snapshot) +{ + return nil == snapshot.additionalAttributes ? nil : snapshot.additionalAttributes[FB_XCAXAIsVisibleAttribute]; +} + @implementation XCUIElement (FBIsVisible) - (BOOL)fb_isVisible { - id snapshot = [self fb_snapshotWithCustomAttributes:@[FB_XCAXAIsVisibleAttributeName] - exludingStandardAttributes:YES - inDepth:NO]; + id snapshot = [self fb_takeSnapshot:NO]; return [FBXCElementSnapshotWrapper ensureWrapped:snapshot].fb_isVisible; } @@ -35,14 +34,43 @@ - (BOOL)fb_isVisible @implementation FBXCElementSnapshotWrapper (FBIsVisible) +- (BOOL)fb_hasVisibleAncestorsOrDescendants +{ + if (nil != [self fb_parentMatchingOneOfTypes:@[@(XCUIElementTypeAny)] + filter:^BOOL(id _Nonnull parent) { + return [fetchSnapshotVisibility(parent) boolValue]; + }]) { + return YES; + } + for (id descendant in (self._allDescendants ?: @[])) { + if ([fetchSnapshotVisibility(descendant) boolValue]) { + return YES; + } + } + return NO; +} + - (BOOL)fb_isVisible { - NSNumber *isVisible = self.additionalAttributes[FB_XCAXAIsVisibleAttribute]; + NSNumber *isVisible = fetchSnapshotVisibility(self); if (isVisible != nil) { return isVisible.boolValue; } - return [(NSNumber *)[self fb_attributeValue:FB_XCAXAIsVisibleAttributeName] boolValue]; + if ([self fb_hasVisibleAncestorsOrDescendants]) { + return YES; + } + + NSError *error = nil; + NSNumber *attributeValue = [self fb_attributeValue:FB_XCAXAIsVisibleAttributeName + timeout:AX_FETCH_TIMEOUT + error:&error]; + if (nil != attributeValue && nil == error) { + return [attributeValue boolValue]; + } + + NSLog(@"Cannot determine element visibility: %@", error.description); + return nil != [self fb_hitPoint]; } @end diff --git a/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.h b/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.h index 000fab374..a16e581f4 100644 --- a/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.h +++ b/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.h @@ -37,38 +37,6 @@ NS_ASSUME_NONNULL_BEGIN */ - (nullable id)fb_cachedSnapshot; -/** - Gets the most recent snapshot of the current element and already resolves the accessibility attributes - needed for creating the page source of this element. No additional calls to the accessibility layer - are required. - Calls to this method mutate the `lastSnapshot` instance property. - - @param inDepth Whether to resolve snapshot parents and children - - @return The recent snapshot of the element with all attributes resolved or a snapshot with default - attributes resolved if there was a failure while resolving additional attributes - @throws FBStaleElementException if the element is not present in DOM and thus no snapshot could be made - */ -- (nullable id)fb_snapshotWithAllAttributes:(BOOL)inDepth; - -/** - Gets the most recent snapshot of the current element with given attributes resolved. - No additional calls to the accessibility layer are required. - Calls to this method mutate the `lastSnapshot` instance property. - - @param customAttributeNames The list of custom attribute names to resolve. Must be one of - FB_...Name values exported by XCTestPrivateSymbols.h module. - `nil` value means that only the default attributes must be extracted - @param inDepth Whether to resolve snapshot parents and children - - @return The recent snapshot of the element with the given attributes resolved or a snapshot with default - attributes resolved if there was a failure while resolving additional attributes - @throws FBStaleElementException if the element is not present in DOM and thus no snapshot could be made -*/ -- (nullable id)fb_snapshotWithCustomAttributes:(nullable NSArray *)customAttributeNames - exludingStandardAttributes:(BOOL)exludingStandardAttributes - inDepth:(BOOL)inDepth; - /** Filters elements by matching them to snapshots from the corresponding array diff --git a/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m b/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m index f9d8b99a4..7b6d52c03 100644 --- a/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m +++ b/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m @@ -42,8 +42,6 @@ #import "XCUIScreen.h" #import "XCUIElement+FBResolve.h" -#define DEFAULT_AX_TIMEOUT 60. - @implementation XCUIElement (FBUtilities) - (id)fb_takeSnapshot:(BOOL)inDepth @@ -72,80 +70,6 @@ @implementation XCUIElement (FBUtilities) return [self.query fb_cachedSnapshot]; } -- (nullable id)fb_snapshotWithAllAttributes:(BOOL)inDepth -{ - return [self fb_snapshotWithCustomAttributes:FBCustomAttributeNames() - exludingStandardAttributes:NO - inDepth:inDepth]; -} - -- (nullable id)fb_snapshotWithCustomAttributes:(NSArray *)customAttributeNames - exludingStandardAttributes:(BOOL)exludingStandardAttributes - inDepth:(BOOL)inDepth -{ - NSTimeInterval axTimeout = FBConfiguration.customSnapshotTimeout; - if (nil == customAttributeNames - || [customAttributeNames count] == 0 - || axTimeout < DBL_EPSILON) { - // return the "normal" element snapshot if no custom attributes are requested - return [self fb_takeSnapshot:inDepth]; - } - - BOOL isSelfApplicationElement = [self isKindOfClass:XCUIApplication.class]; - id axElement = isSelfApplicationElement - ? [(XCUIApplication *)self accessibilityElement] - : [[self fb_takeSnapshot:inDepth] accessibilityElement]; - if (nil == axElement) { - return nil; - } - - NSError *setTimeoutError; - BOOL isTimeoutSet = [FBXCAXClientProxy.sharedClient setAXTimeout:axTimeout - error:&setTimeoutError]; - if (!isTimeoutSet) { - [FBLogger logFmt:@"Cannot set snapshoting timeout to %.1fs. Original error: %@", - axTimeout, setTimeoutError.localizedDescription]; - } - - NSError *error; - NSMutableArray *attributeNames = [NSMutableArray arrayWithArray:exludingStandardAttributes ? @[] : FBStandardAttributeNames()]; - [attributeNames addObjectsFromArray:customAttributeNames ?: @[]]; - BOOL requiresFullTreeSnapshot = isSelfApplicationElement || inDepth; - id appAxElement = isSelfApplicationElement ? axElement : self.application.accessibilityElement; - id snapshotWithAttributes = [FBXCAXClientProxy.sharedClient snapshotForElement:requiresFullTreeSnapshot ? appAxElement : axElement - attributes:attributeNames.copy - inDepth:requiresFullTreeSnapshot - error:&error]; - NSString *axElementUid = [FBElementUtils uidWithAccessibilityElement:axElement]; - if (nil != snapshotWithAttributes && nil != axElementUid && !isSelfApplicationElement) { - NSArray *matches = [snapshotWithAttributes descendantsByFilteringWithBlock:^BOOL(id _Nonnull snapshot) { - return [[FBElementUtils uidWithAccessibilityElement:snapshot.accessibilityElement] isEqualToString:axElementUid]; - }]; - if ([matches count] > 0) { - snapshotWithAttributes = [matches objectAtIndex:0]; - } - } - if (nil == snapshotWithAttributes) { - if (isSelfApplicationElement || !inDepth) { - [self fb_takeSnapshot:YES]; - } - NSString *description = [FBXCElementSnapshotWrapper ensureWrapped:self.lastSnapshot].fb_description; - [FBLogger logFmt:@"Cannot take a snapshot with attribute(s) %@ of '%@' after %.2f seconds", - attributeNames, description, axTimeout]; - [FBLogger logFmt:@"This timeout could be customized via '%@' setting", FB_SETTING_CUSTOM_SNAPSHOT_TIMEOUT]; - [FBLogger logFmt:@"Internal error: %@", error.localizedDescription]; - [FBLogger logFmt:@"Falling back to the default snapshotting mechanism for the element '%@' (some attribute values, like visibility or accessibility might not be precise though)", description]; - snapshotWithAttributes = self.lastSnapshot; - } else { - self.lastSnapshot = snapshotWithAttributes; - } - - if (isTimeoutSet) { - [FBXCAXClientProxy.sharedClient setAXTimeout:DEFAULT_AX_TIMEOUT error:nil]; - } - return snapshotWithAttributes; -} - - (NSArray *)fb_filterDescendantsWithSnapshots:(NSArray> *)snapshots selfUID:(NSString *)selfUID onlyChildren:(BOOL)onlyChildren diff --git a/WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.m b/WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.m index 5fb517a03..ffc962102 100644 --- a/WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.m +++ b/WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.m @@ -31,23 +31,6 @@ @implementation XCUIElement (WebDriverAttributesForwarding) BOOL inDepth = [name isEqualToString:FBStringify(XCUIElement, isWDAccessible)] || [name isEqualToString:FBStringify(XCUIElement, isWDAccessibilityContainer)] || [name isEqualToString:FBStringify(XCUIElement, wdIndex)]; - - // These attributes are special, because we can only retrieve them from - // the snapshot if we explicitly ask XCTest to include them into the query while taking it. - // That is why fb_snapshotWithAllAttributes method must be used instead of the default snapshot - // call - if ([name isEqualToString:FBStringify(XCUIElement, isWDVisible)]) { - return [self fb_snapshotWithCustomAttributes:@[FB_XCAXAIsVisibleAttributeName] - exludingStandardAttributes:YES - inDepth:inDepth]; - } - if ([name isEqualToString:FBStringify(XCUIElement, isWDAccessible)] - || [name isEqualToString:FBStringify(XCUIElement, isWDAccessibilityContainer)]) { - return [self fb_snapshotWithCustomAttributes:@[FB_XCAXAIsElementAttributeName] - exludingStandardAttributes:NO - inDepth:inDepth]; - } - return [self fb_takeSnapshot:inDepth]; } @@ -186,8 +169,8 @@ - (BOOL)isWDAccessible // In the scenario when table provides Search results controller, table could be marked as accessible element, even though it isn't // As it is highly unlikely that table view should ever be an accessibility element itself, // for now we work around that by skipping Table View in container checks - if ([FBXCElementSnapshotWrapper ensureWrapped:parentSnapshot].fb_isAccessibilityElement - && parentSnapshot.elementType != XCUIElementTypeTable) { + if (parentSnapshot.elementType != XCUIElementTypeTable + && [FBXCElementSnapshotWrapper ensureWrapped:parentSnapshot].fb_isAccessibilityElement) { return NO; } parentSnapshot = parentSnapshot.parent; diff --git a/WebDriverAgentLib/Utilities/FBXCAXClientProxy.h b/WebDriverAgentLib/Utilities/FBXCAXClientProxy.h index c2a2f0178..409042696 100644 --- a/WebDriverAgentLib/Utilities/FBXCAXClientProxy.h +++ b/WebDriverAgentLib/Utilities/FBXCAXClientProxy.h @@ -10,6 +10,8 @@ #import #import "FBXCElementSnapshot.h" +extern const NSTimeInterval FBDefaultAxTimeout; + @protocol FBXCAccessibilityElement; NS_ASSUME_NONNULL_BEGIN @@ -39,8 +41,9 @@ NS_ASSUME_NONNULL_BEGIN - (void)notifyWhenNoAnimationsAreActiveForApplication:(XCUIApplication *)application reply:(void (^)(void))reply; -- (NSDictionary *)attributesForElement:(id)element - attributes:(NSArray *)attributes; +- (nullable NSDictionary *)attributesForElement:(id)element + attributes:(NSArray *)attributes + error:(NSError**)error; - (XCUIApplication *)monitoredApplicationWithProcessIdentifier:(int)pid; diff --git a/WebDriverAgentLib/Utilities/FBXCAXClientProxy.m b/WebDriverAgentLib/Utilities/FBXCAXClientProxy.m index bd715ff34..53f825e55 100644 --- a/WebDriverAgentLib/Utilities/FBXCAXClientProxy.m +++ b/WebDriverAgentLib/Utilities/FBXCAXClientProxy.m @@ -17,6 +17,8 @@ static id FBAXClient = nil; +const NSTimeInterval FBDefaultAxTimeout = 60.0; + @implementation FBXCAXClientProxy + (instancetype)sharedClient @@ -76,15 +78,11 @@ - (void)notifyWhenNoAnimationsAreActiveForApplication:(XCUIApplication *)applica - (NSDictionary *)attributesForElement:(id)element attributes:(NSArray *)attributes + error:(NSError**)error; { - NSError *error = nil; - NSDictionary* result = [FBAXClient attributesForElement:element - attributes:attributes - error:&error]; - if (error) { - [FBLogger logFmt:@"Cannot retrieve element attribute(s) %@. Original error: %@", attributes, error.description]; - } - return result; + return [FBAXClient attributesForElement:element + attributes:attributes + error:error]; } - (XCUIApplication *)monitoredApplicationWithProcessIdentifier:(int)pid diff --git a/WebDriverAgentLib/Utilities/FBXPath.m b/WebDriverAgentLib/Utilities/FBXPath.m index eea6a8726..8a3cc2d60 100644 --- a/WebDriverAgentLib/Utilities/FBXPath.m +++ b/WebDriverAgentLib/Utilities/FBXPath.m @@ -368,19 +368,12 @@ + (int)writeXmlWithRootElement:(id)root NSArray> *children; if ([root isKindOfClass:XCUIElement.class]) { XCUIElement *element = (XCUIElement *)root; - NSMutableArray *customAttributes = [NSMutableArray array]; if (nil == includedAttributes || [includedAttributes containsObject:FBVisibleAttribute.class]) { - [customAttributes addObject:FB_XCAXAIsVisibleAttributeName]; // If the app is not idle state while we retrieve the visiblity state // then the snapshot retrieval operation might freeze and time out [element.application fb_waitUntilStableWithTimeout:FBConfiguration.animationCoolOffTimeout]; } - if (nil == includedAttributes || [includedAttributes containsObject:FBAccessibleAttribute.class]) { - [customAttributes addObject:FB_XCAXAIsElementAttributeName]; - } - currentSnapshot = [element fb_snapshotWithCustomAttributes:customAttributes.copy - exludingStandardAttributes:NO - inDepth:YES]; + currentSnapshot = [element fb_takeSnapshot:YES]; children = currentSnapshot.children; } else { currentSnapshot = (id)root; diff --git a/WebDriverAgentLib/Utilities/XCTestPrivateSymbols.h b/WebDriverAgentLib/Utilities/XCTestPrivateSymbols.h index 87199ff35..da99cfd58 100644 --- a/WebDriverAgentLib/Utilities/XCTestPrivateSymbols.h +++ b/WebDriverAgentLib/Utilities/XCTestPrivateSymbols.h @@ -19,6 +19,9 @@ extern NSString *FB_XCAXAIsVisibleAttributeName; extern NSNumber *FB_XCAXAIsElementAttribute; extern NSString *FB_XCAXAIsElementAttributeName; +/*! Accessibility identifier for visible frame attribute */ +extern NSString *FB_XCAXAVisibleFrameAttributeName; + /*! Getter for XCTest logger */ extern id (*XCDebugLogger)(void); diff --git a/WebDriverAgentLib/Utilities/XCTestPrivateSymbols.m b/WebDriverAgentLib/Utilities/XCTestPrivateSymbols.m index 861a78660..502a6f8b7 100644 --- a/WebDriverAgentLib/Utilities/XCTestPrivateSymbols.m +++ b/WebDriverAgentLib/Utilities/XCTestPrivateSymbols.m @@ -18,6 +18,7 @@ NSString *FB_XCAXAIsVisibleAttributeName = @"XC_kAXXCAttributeIsVisible"; NSNumber *FB_XCAXAIsElementAttribute; NSString *FB_XCAXAIsElementAttributeName = @"XC_kAXXCAttributeIsElement"; +NSString *FB_XCAXAVisibleFrameAttributeName = @"XC_kAXXCAttributeVisibleFrame"; void (*XCSetDebugLogger)(id ); id (*XCDebugLogger)(void); diff --git a/WebDriverAgentTests/IntegrationTests/FBElementSwipingTests.m b/WebDriverAgentTests/IntegrationTests/FBElementSwipingTests.m index 0a9d2f5c4..ec5c853d0 100644 --- a/WebDriverAgentTests/IntegrationTests/FBElementSwipingTests.m +++ b/WebDriverAgentTests/IntegrationTests/FBElementSwipingTests.m @@ -72,7 +72,7 @@ - (void)testSwipeDownWithVelocity } [self.scrollView fb_swipeWithDirection:@"up" velocity:@2500]; FBAssertInvisibleCell(@"0"); - [self.scrollView fb_swipeWithDirection:@"down" velocity:@2500]; + [self.scrollView fb_swipeWithDirection:@"down" velocity:@3000]; FBAssertVisibleCell(@"0"); } diff --git a/WebDriverAgentTests/IntegrationTests/FBXPathIntegrationTests.m b/WebDriverAgentTests/IntegrationTests/FBXPathIntegrationTests.m index 30c7ee84a..a3b81c459 100644 --- a/WebDriverAgentTests/IntegrationTests/FBXPathIntegrationTests.m +++ b/WebDriverAgentTests/IntegrationTests/FBXPathIntegrationTests.m @@ -43,7 +43,7 @@ - (void)setUp - (id)destinationSnapshot { XCUIElement *matchingElement = self.testedView.buttons.allElementsBoundByIndex.firstObject; - FBAssertWaitTillBecomesTrue(nil != [matchingElement fb_snapshotWithAllAttributes:YES]); + FBAssertWaitTillBecomesTrue(nil != [matchingElement fb_takeSnapshot:YES]); id snapshot = matchingElement.lastSnapshot; // Over iOS13, snapshot returns a child. diff --git a/WebDriverAgentTests/UnitTests/Doubles/XCElementSnapshotDouble.m b/WebDriverAgentTests/UnitTests/Doubles/XCElementSnapshotDouble.m index d52c2904c..b3422ee46 100644 --- a/WebDriverAgentTests/UnitTests/Doubles/XCElementSnapshotDouble.m +++ b/WebDriverAgentTests/UnitTests/Doubles/XCElementSnapshotDouble.m @@ -98,4 +98,9 @@ - (NSArray *)children return @[]; } +- (NSArray *)_allDescendants +{ + return @[]; +} + @end