diff --git a/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m b/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m index ac3d07ce9..7e555b2b5 100644 --- a/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +++ b/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m @@ -37,6 +37,7 @@ #import "XCUIElement+FBUtilities.h" #import "XCUIElement+FBWebDriverAttributes.h" #import "XCUIElementQuery.h" +#import "FBConfiguration.h" static NSString* const FBUnknownBundleId = @"unknown"; @@ -176,7 +177,7 @@ - (NSDictionary *)fb_tree - (NSDictionary *)fb_tree:(nullable NSSet *)excludedAttributes { - id snapshot = [self fb_takeSnapshot:YES]; + id snapshot = [self fb_takeSnapshot:[FBConfiguration inDepthSnapshot]]; return [self.class dictionaryForElement:snapshot recursive:YES excludedAttributes:excludedAttributes]; diff --git a/WebDriverAgentLib/Commands/FBSessionCommands.m b/WebDriverAgentLib/Commands/FBSessionCommands.m index 67b6b81e9..8d4b61f0a 100644 --- a/WebDriverAgentLib/Commands/FBSessionCommands.m +++ b/WebDriverAgentLib/Commands/FBSessionCommands.m @@ -337,6 +337,7 @@ + (NSArray *)routes FB_SETTING_KEYBOARD_AUTOCORRECTION: @([FBConfiguration keyboardAutocorrection]), FB_SETTING_KEYBOARD_PREDICTION: @([FBConfiguration keyboardPrediction]), FB_SETTING_SNAPSHOT_MAX_DEPTH: @([FBConfiguration snapshotMaxDepth]), + FB_SETTING_IN_DEPTH_SNAPSHOT: @([FBConfiguration inDepthSnapshot]), FB_SETTING_USE_FIRST_MATCH: @([FBConfiguration useFirstMatch]), FB_SETTING_WAIT_FOR_IDLE_TIMEOUT: @([FBConfiguration waitForIdleTimeout]), FB_SETTING_ANIMATION_COOL_OFF_TIMEOUT: @([FBConfiguration animationCoolOffTimeout]), @@ -398,6 +399,9 @@ + (NSArray *)routes if (nil != [settings objectForKey:FB_SETTING_SNAPSHOT_MAX_DEPTH]) { [FBConfiguration setSnapshotMaxDepth:[[settings objectForKey:FB_SETTING_SNAPSHOT_MAX_DEPTH] intValue]]; } + if (nil != [settings objectForKey:FB_SETTING_IN_DEPTH_SNAPSHOT]) { + [FBConfiguration setInDepthSnapshot:[[settings objectForKey:FB_SETTING_IN_DEPTH_SNAPSHOT] boolValue]]; + } if (nil != [settings objectForKey:FB_SETTING_USE_FIRST_MATCH]) { [FBConfiguration setUseFirstMatch:[[settings objectForKey:FB_SETTING_USE_FIRST_MATCH] boolValue]]; } diff --git a/WebDriverAgentLib/Utilities/FBConfiguration.h b/WebDriverAgentLib/Utilities/FBConfiguration.h index cb0a67dcf..43df826b0 100644 --- a/WebDriverAgentLib/Utilities/FBConfiguration.h +++ b/WebDriverAgentLib/Utilities/FBConfiguration.h @@ -201,6 +201,24 @@ typedef NS_ENUM(NSInteger, FBConfigurationKeyboardPreference) { */ + (int)snapshotMaxDepth; +/** + * Sets whether to take a deep snapshot of the application elements. + * When enabled, the snapshot captures more detailed information about the UI hierarchy. + * This may be useful for complex views but can impact performance. + * + * @param value A boolean value indicating whether to enable deep snapshots. + * Pass YES for a detailed snapshot, NO for a faster but less detailed one. + */ ++ (void)setInDepthSnapshot:(BOOL)value; + +/** + * Gets the current setting for in-depth snapshot capturing. + * If enabled, snapshots will include more detailed UI information. + * + * @return A boolean indicating whether in-depth snapshots are enabled. + */ ++ (BOOL)inDepthSnapshot; + /** * Whether to use fast search result matching while searching for elements. * By default this is disabled due to https://github.com/appium/appium/issues/10101 diff --git a/WebDriverAgentLib/Utilities/FBConfiguration.m b/WebDriverAgentLib/Utilities/FBConfiguration.m index f3cf8e42f..54869e95e 100644 --- a/WebDriverAgentLib/Utilities/FBConfiguration.m +++ b/WebDriverAgentLib/Utilities/FBConfiguration.m @@ -36,6 +36,7 @@ static BOOL FBShouldUseTestManagerForVisibilityDetection = NO; static BOOL FBShouldUseSingletonTestManager = YES; static BOOL FBShouldRespectSystemAlerts = NO; +static BOOL FBInDepthSnapshot = YES; static NSUInteger FBMjpegScalingFactor = 100; static BOOL FBMjpegShouldFixOrientation = NO; @@ -369,6 +370,14 @@ + (int)snapshotMaxDepth return [FBGetCustomParameterForElementSnapshot(FBSnapshotMaxDepthKey) intValue]; } ++ (void)setInDepthSnapshot:(BOOL)value { + FBInDepthSnapshot = value; +} + ++ (BOOL)inDepthSnapshot { + return FBInDepthSnapshot; +} + + (void)setShouldRespectSystemAlerts:(BOOL)value { FBShouldRespectSystemAlerts = value; diff --git a/WebDriverAgentLib/Utilities/FBSettings.h b/WebDriverAgentLib/Utilities/FBSettings.h index 7f6d57970..952830b97 100644 --- a/WebDriverAgentLib/Utilities/FBSettings.h +++ b/WebDriverAgentLib/Utilities/FBSettings.h @@ -23,6 +23,7 @@ extern NSString* const FB_SETTING_SCREENSHOT_QUALITY; extern NSString* const FB_SETTING_KEYBOARD_AUTOCORRECTION; extern NSString* const FB_SETTING_KEYBOARD_PREDICTION; extern NSString* const FB_SETTING_SNAPSHOT_MAX_DEPTH; +extern NSString* const FB_SETTING_IN_DEPTH_SNAPSHOT; extern NSString* const FB_SETTING_USE_FIRST_MATCH; extern NSString* const FB_SETTING_BOUND_ELEMENTS_BY_INDEX; extern NSString* const FB_SETTING_REDUCE_MOTION; diff --git a/WebDriverAgentLib/Utilities/FBSettings.m b/WebDriverAgentLib/Utilities/FBSettings.m index d91e343ed..916e4b904 100644 --- a/WebDriverAgentLib/Utilities/FBSettings.m +++ b/WebDriverAgentLib/Utilities/FBSettings.m @@ -19,6 +19,7 @@ NSString* const FB_SETTING_KEYBOARD_AUTOCORRECTION = @"keyboardAutocorrection"; NSString* const FB_SETTING_KEYBOARD_PREDICTION = @"keyboardPrediction"; NSString* const FB_SETTING_SNAPSHOT_MAX_DEPTH = @"snapshotMaxDepth"; +NSString* const FB_SETTING_IN_DEPTH_SNAPSHOT = @"inDepthSnapshot"; NSString* const FB_SETTING_USE_FIRST_MATCH = @"useFirstMatch"; NSString* const FB_SETTING_BOUND_ELEMENTS_BY_INDEX = @"boundElementsByIndex"; NSString* const FB_SETTING_REDUCE_MOTION = @"reduceMotion";