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
4 changes: 4 additions & 0 deletions WebDriverAgentLib/Commands/FBSessionCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ + (NSArray *)routes
FB_SETTING_MAX_TYPING_FREQUENCY: @([FBConfiguration maxTypingFrequency]),
FB_SETTING_RESPECT_SYSTEM_ALERTS: @([FBConfiguration shouldRespectSystemAlerts]),
FB_SETTING_USE_CLEAR_TEXT_SHORTCUT: @([FBConfiguration useClearTextShortcut]),
FB_SETTING_INCLUDE_HITTABLE_IN_PAGE_SOURCE: @([FBConfiguration includeHittableInPageSource]),
FB_SETTING_LIMIT_XPATH_CONTEXT_SCOPE: @([FBConfiguration limitXpathContextScope]),
#if !TARGET_OS_TV
FB_SETTING_SCREENSHOT_ORIENTATION: [FBConfiguration humanReadableScreenshotOrientation],
Expand Down Expand Up @@ -455,6 +456,9 @@ + (NSArray *)routes
if (nil != [settings objectForKey:FB_SETTING_USE_CLEAR_TEXT_SHORTCUT]) {
[FBConfiguration setUseClearTextShortcut:[[settings objectForKey:FB_SETTING_USE_CLEAR_TEXT_SHORTCUT] boolValue]];
}
if (nil != [settings objectForKey:FB_SETTING_INCLUDE_HITTABLE_IN_PAGE_SOURCE]) {
[FBConfiguration setincludeHittableInPageSource:[[settings objectForKey:FB_SETTING_INCLUDE_HITTABLE_IN_PAGE_SOURCE] boolValue]];
}
if (nil != [settings objectForKey:FB_SETTING_LIMIT_XPATH_CONTEXT_SCOPE]) {
[FBConfiguration setLimitXpathContextScope:[[settings objectForKey:FB_SETTING_LIMIT_XPATH_CONTEXT_SCOPE] boolValue]];
}
Expand Down
11 changes: 11 additions & 0 deletions WebDriverAgentLib/Utilities/FBConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,17 @@ typedef NS_ENUM(NSInteger, FBConfigurationKeyboardPreference) {
*/
+ (void)resetSessionSettings;

/**
* Whether to calculate `hittable` attribute using native APIs
* instead of legacy heuristics.
* This flag improves accuracy, but may affect performance.
* Disabled by default.
*
* @param enabled Either YES or NO
*/
+ (void)setincludeHittableInPageSource:(BOOL)enabled;
+ (BOOL)includeHittableInPageSource;

@end

NS_ASSUME_NONNULL_END
11 changes: 11 additions & 0 deletions WebDriverAgentLib/Utilities/FBConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#if !TARGET_OS_TV
static UIInterfaceOrientation FBScreenshotOrientation;
#endif
static BOOL FBShouldincludeHittableInPageSource = NO;

@implementation FBConfiguration

Expand Down Expand Up @@ -642,4 +643,14 @@ + (BOOL)reduceMotionEnabled
return NO;
}

+ (void)setincludeHittableInPageSource:(BOOL)enabled
{
FBShouldincludeHittableInPageSource = enabled;
}

+ (BOOL)includeHittableInPageSource
{
return FBShouldincludeHittableInPageSource;
}

@end
1 change: 1 addition & 0 deletions WebDriverAgentLib/Utilities/FBSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ extern NSString* const FB_SETTING_RESPECT_SYSTEM_ALERTS;
extern NSString* const FB_SETTING_USE_CLEAR_TEXT_SHORTCUT;
extern NSString* const FB_SETTING_LIMIT_XPATH_CONTEXT_SCOPE;
extern NSString* const FB_SETTING_AUTO_CLICK_ALERT_SELECTOR;
extern NSString *const FB_SETTING_INCLUDE_HITTABLE_IN_PAGE_SOURCE;


NS_ASSUME_NONNULL_END
1 change: 1 addition & 0 deletions WebDriverAgentLib/Utilities/FBSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@
NSString* const FB_SETTING_USE_CLEAR_TEXT_SHORTCUT = @"useClearTextShortcut";
NSString* const FB_SETTING_LIMIT_XPATH_CONTEXT_SCOPE = @"limitXPathContextScope";
NSString* const FB_SETTING_AUTO_CLICK_ALERT_SELECTOR = @"autoClickAlertSelector";
NSString* const FB_SETTING_INCLUDE_HITTABLE_IN_PAGE_SOURCE = @"includeHittableInPageSource";
13 changes: 9 additions & 4 deletions WebDriverAgentLib/Utilities/FBXPath.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ + (nullable NSString *)xmlStringWithRootElement:(id<FBElement>)root

if (rc >= 0) {
[self waitUntilStableWithElement:root];
rc = [self xmlRepresentationWithRootElement:[self snapshotWithRoot:root useNative:NO]
// If 'includeHittableInPageSource' setting is enabled, then use native snapshots
// to calculate a more accurate value for the 'hittable' attribute.
rc = [self xmlRepresentationWithRootElement:[self snapshotWithRoot:root
useNative:FBConfiguration.includeHittableInPageSource]
writer:writer
elementStore:nil
query:nil
Expand Down Expand Up @@ -354,9 +357,11 @@ + (int)xmlRepresentationWithRootElement:(id<FBXCElementSnapshot>)root
NSMutableSet<Class> *includedAttributes;
if (nil == query) {
includedAttributes = [NSMutableSet setWithArray:FBElementAttribute.supportedAttributes];
// The hittable attribute is expensive to calculate for each snapshot item
// thus we only include it when requested by an xPath query
[includedAttributes removeObject:FBHittableAttribute.class];
if (!FBConfiguration.includeHittableInPageSource) {
// The hittable attribute is expensive to calculate for each snapshot item
// thus we only include it when requested explicitly
[includedAttributes removeObject:FBHittableAttribute.class];
}
if (nil != excludedAttributes) {
for (NSString *excludedAttributeName in excludedAttributes) {
for (Class supportedAttribute in FBElementAttribute.supportedAttributes) {
Expand Down
Loading