Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

NS_ASSUME_NONNULL_BEGIN

extern NSString *const FBSnapshotMaxChildrenKey;
extern NSString *const FBSnapshotMaxDepthKey;

void FBSetCustomParameterForElementSnapshot (NSString* name, id value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@"maxDepth" : (int)2147483647
*/
NSString *const FBSnapshotMaxDepthKey = @"maxDepth";
NSString *const FBSnapshotMaxChildrenKey = @"maxChildren";

static id (*original_defaultParameters)(id, SEL);
static id (*original_snapshotParameters)(id, SEL);
Expand Down
4 changes: 4 additions & 0 deletions WebDriverAgentLib/Commands/FBSessionCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -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_SNAPSHOT_MAX_CHILDREN: @([FBConfiguration snapshotMaxChildren]),
FB_SETTING_USE_FIRST_MATCH: @([FBConfiguration useFirstMatch]),
FB_SETTING_WAIT_FOR_IDLE_TIMEOUT: @([FBConfiguration waitForIdleTimeout]),
FB_SETTING_ANIMATION_COOL_OFF_TIMEOUT: @([FBConfiguration animationCoolOffTimeout]),
Expand Down Expand Up @@ -404,6 +405,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_SNAPSHOT_MAX_CHILDREN]) {
[FBConfiguration setSnapshotMaxChildren:[[settings objectForKey:FB_SETTING_SNAPSHOT_MAX_CHILDREN] intValue]];
}
if (nil != [settings objectForKey:FB_SETTING_USE_FIRST_MATCH]) {
[FBConfiguration setUseFirstMatch:[[settings objectForKey:FB_SETTING_USE_FIRST_MATCH] boolValue]];
}
Expand Down
17 changes: 17 additions & 0 deletions WebDriverAgentLib/Utilities/FBConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

NS_ASSUME_NONNULL_BEGIN

extern NSString *const FBSnapshotMaxChildrenKey;
extern NSString *const FBSnapshotMaxDepthKey;

/**
Expand Down Expand Up @@ -206,6 +207,22 @@ typedef NS_ENUM(NSInteger, FBConfigurationKeyboardPreference) {
*/
+ (int)snapshotMaxDepth;

/**
Sets the maximum number of element children to traverse in each snapshot
while requesting XCElementSnapshot.
Used to set the `maxChildren` value in a dictionary provided by
XCAXClient_iOS's `defaultParameters` method.
The original XCAXClient_iOS `maxChildren` value is `INT_MAX`.

@param maxChildren The number of maximum element children for traversing elements tree
*/
+ (void)setSnapshotMaxChildren:(int)maxChildren;

/**
@return The maximum number of element children for traversing elements tree
*/
+ (int)snapshotMaxChildren;

/**
* 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
Expand Down
12 changes: 12 additions & 0 deletions WebDriverAgentLib/Utilities/FBConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import "TIPreferencesController.h"

#include <dlfcn.h>
#include <limits.h>
#import <UIKit/UIKit.h>

#include "TargetConditionals.h"
Expand Down Expand Up @@ -385,6 +386,16 @@ + (int)snapshotMaxDepth
return [FBGetCustomParameterForElementSnapshot(FBSnapshotMaxDepthKey) intValue];
}

+ (void)setSnapshotMaxChildren:(int)maxChildren
{
FBSetCustomParameterForElementSnapshot(FBSnapshotMaxChildrenKey, @(maxChildren));
}

+ (int)snapshotMaxChildren
{
return [FBGetCustomParameterForElementSnapshot(FBSnapshotMaxChildrenKey) intValue];
}

+ (void)setShouldRespectSystemAlerts:(BOOL)value
{
FBShouldRespectSystemAlerts = value;
Expand Down Expand Up @@ -541,6 +552,7 @@ + (void)resetSessionSettings
FBAnimationCoolOffTimeout = 2.;
// 50 should be enough for the majority of the cases. The performance is acceptable for values up to 100.
FBSetCustomParameterForElementSnapshot(FBSnapshotMaxDepthKey, @50);
FBSetCustomParameterForElementSnapshot(FBSnapshotMaxChildrenKey, @INT_MAX);
FBUseClearTextShortcut = YES;
FBLimitXpathContextScope = YES;
#if !TARGET_OS_TV
Expand Down
1 change: 1 addition & 0 deletions WebDriverAgentLib/Utilities/FBSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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_SNAPSHOT_MAX_CHILDREN;
extern NSString* const FB_SETTING_USE_FIRST_MATCH;
extern NSString* const FB_SETTING_BOUND_ELEMENTS_BY_INDEX;
extern NSString* const FB_SETTING_REDUCE_MOTION;
Expand Down
1 change: 1 addition & 0 deletions WebDriverAgentLib/Utilities/FBSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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_SNAPSHOT_MAX_CHILDREN = @"snapshotMaxChildren";
NSString* const FB_SETTING_USE_FIRST_MATCH = @"useFirstMatch";
NSString* const FB_SETTING_BOUND_ELEMENTS_BY_INDEX = @"boundElementsByIndex";
NSString* const FB_SETTING_REDUCE_MOTION = @"reduceMotion";
Expand Down
1 change: 1 addition & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface WDASettings {
keyboardPrediction?: boolean;
customSnapshotTimeout?: number;
snapshotMaxDepth?: number;
snapshotMaxChildren?: number;
useFirstMatch?: boolean;
boundElementsByIndex?: boolean;
reduceMotion?: boolean;
Expand Down
Loading