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
6 changes: 5 additions & 1 deletion WebDriverAgentLib/Commands/FBSessionCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ + (NSArray *)routes
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_INCLUDE_NATIVE_FRAME_IN_PAGE_SOURCE: @([FBConfiguration includeNativeFrameInPageSource]),
FB_SETTING_LIMIT_XPATH_CONTEXT_SCOPE: @([FBConfiguration limitXpathContextScope]),
#if !TARGET_OS_TV
FB_SETTING_SCREENSHOT_ORIENTATION: [FBConfiguration humanReadableScreenshotOrientation],
Expand Down Expand Up @@ -457,7 +458,10 @@ + (NSArray *)routes
[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]];
[FBConfiguration setIncludeHittableInPageSource:[[settings objectForKey:FB_SETTING_INCLUDE_HITTABLE_IN_PAGE_SOURCE] boolValue]];
}
if (nil != [settings objectForKey:FB_SETTING_INCLUDE_NATIVE_FRAME_IN_PAGE_SOURCE]) {
[FBConfiguration setIncludeNativeFrameInPageSource:[[settings objectForKey:FB_SETTING_INCLUDE_NATIVE_FRAME_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
18 changes: 17 additions & 1 deletion WebDriverAgentLib/Utilities/FBConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,25 @@ typedef NS_ENUM(NSInteger, FBConfigurationKeyboardPreference) {
*
* @param enabled Either YES or NO
*/
+ (void)setincludeHittableInPageSource:(BOOL)enabled;
+ (void)setIncludeHittableInPageSource:(BOOL)enabled;
+ (BOOL)includeHittableInPageSource;

/**
* Whether to include `nativeFrame` attribute in the XML page source.
*
* When enabled, the XML representation will contain the precise rendered
* frame of the UI element.
*
* This value is more accurate than the legacy `wdFrame`, which applies rounding
* and may introduce inconsistencies in size and position calculations.
*
* The value is disabled by default to avoid potential performance overhead.
*
* @param enabled Either YES or NO
*/
+ (void)setIncludeNativeFrameInPageSource:(BOOL)enabled;
+ (BOOL)includeNativeFrameInPageSource;

@end

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

@implementation FBConfiguration

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

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

+ (BOOL)includeHittableInPageSource
{
return FBShouldincludeHittableInPageSource;
return FBShouldIncludeHittableInPageSource;
}

+ (void)setIncludeNativeFrameInPageSource:(BOOL)enabled
{
FBShouldIncludeNativeFrameInPageSource = enabled;
}

+ (BOOL)includeNativeFrameInPageSource
{
return FBShouldIncludeNativeFrameInPageSource;
}

@end
1 change: 1 addition & 0 deletions WebDriverAgentLib/Utilities/FBSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ 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;
extern NSString *const FB_SETTING_INCLUDE_NATIVE_FRAME_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 @@ -37,3 +37,4 @@
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";
NSString* const FB_SETTING_INCLUDE_NATIVE_FRAME_IN_PAGE_SOURCE = @"includeNativeFrameInPageSource";
21 changes: 21 additions & 0 deletions WebDriverAgentLib/Utilities/FBXPath.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ @interface FBPlaceholderValueAttribute : FBElementAttribute

@end

@interface FBNativeFrameAttribute : FBElementAttribute

@end

@interface FBTraitsAttribute : FBElementAttribute

@end
Expand Down Expand Up @@ -366,6 +370,10 @@ + (int)xmlRepresentationWithRootElement:(id<FBXCElementSnapshot>)root
// thus we only include it when requested explicitly
[includedAttributes removeObject:FBHittableAttribute.class];
}
if (!FBConfiguration.includeNativeFrameInPageSource) {
// Include nativeFrame only when requested
[includedAttributes removeObject:FBNativeFrameAttribute.class];
}
if (nil != excludedAttributes) {
for (NSString *excludedAttributeName in excludedAttributes) {
for (Class supportedAttribute in FBElementAttribute.supportedAttributes) {
Expand Down Expand Up @@ -588,6 +596,7 @@ + (int)recordWithWriter:(xmlTextWriterPtr)writer forElement:(id<FBElement>)eleme
FBHittableAttribute.class,
FBPlaceholderValueAttribute.class,
FBTraitsAttribute.class,
FBNativeFrameAttribute.class,
];
}

Expand Down Expand Up @@ -823,7 +832,19 @@ + (NSString *)valueForElement:(id<FBElement>)element
{
return element.wdPlaceholderValue;
}
@end

@implementation FBNativeFrameAttribute

+ (NSString *)name
{
return @"nativeFrame";
}

+ (NSString *)valueForElement:(id<FBElement>)element
{
return NSStringFromCGRect(element.wdNativeFrame);
}
@end

@implementation FBTraitsAttribute
Expand Down
6 changes: 3 additions & 3 deletions WebDriverAgentTests/UnitTests/FBXPathTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ - (void)testtXPathPresentationWithSomeAttributesExcluded
id<FBElement> element = (id<FBElement>)[FBXCElementSnapshotWrapper ensureWrapped:(id)snapshot];
NSString *resultXml = [self xmlStringWithElement:(id<FBXCElementSnapshot>)element
xpathQuery:nil
excludingAttributes:@[@"type", @"visible", @"value", @"index", @"traits"]];
excludingAttributes:@[@"type", @"visible", @"value", @"index", @"traits", @"nativeFrame"]];
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ name=\"%@\" label=\"%@\" enabled=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" placeholderValue=\"%@\" private_indexPath=\"top\"/>\n",
element.wdType, element.wdName, element.wdLabel, FBBoolToString(element.wdEnabled), FBBoolToString(element.wdAccessible), element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"], element.wdPlaceholderValue];
XCTAssertEqualObjects(resultXml, expectedXml);
Expand All @@ -90,8 +90,8 @@ - (void)testXPathPresentationBasedOnQueryMatchingAllAttributes
NSString *resultXml = [self xmlStringWithElement:(id<FBXCElementSnapshot>)element
xpathQuery:[NSString stringWithFormat:@"//%@[@*]", element.wdType]
excludingAttributes:@[@"visible"]];
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" value=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" hittable=\"%@\" placeholderValue=\"%@\" traits=\"%@\" private_indexPath=\"top\"/>\n",
element.wdType, element.wdType, @"йоло&lt;&gt;&amp;&quot;", element.wdName, @"a&#10;b", FBBoolToString(element.wdEnabled), FBBoolToString(element.wdVisible), FBBoolToString(element.wdAccessible), element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"], element.wdIndex, FBBoolToString(element.wdHittable), element.wdPlaceholderValue, element.wdTraits];
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" value=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" hittable=\"%@\" placeholderValue=\"%@\" traits=\"%@\" nativeFrame=\"%@\" private_indexPath=\"top\"/>\n",
element.wdType, element.wdType, @"йоло&lt;&gt;&amp;&quot;", element.wdName, @"a&#10;b", FBBoolToString(element.wdEnabled), FBBoolToString(element.wdVisible), FBBoolToString(element.wdAccessible), element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"], element.wdIndex, FBBoolToString(element.wdHittable), element.wdPlaceholderValue, element.wdTraits, NSStringFromCGRect(element.wdNativeFrame)];
XCTAssertEqualObjects(expectedXml, resultXml);
}

Expand Down
Loading