Skip to content

Commit 7e9dbb4

Browse files
refactor: use FBDoesElementSupportInnerText and clarify helper method comment
- Replaced custom placeholder support check with FBDoesElementSupportInnerText, as introduced in upstream PR - Updated comment for fb_attributeBlockMapForSnapshot to clarify usage context and avoid confusion about method placement
1 parent 94a6f66 commit 7e9dbb4

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

WebDriverAgentLib/Categories/FBXCElementSnapshotWrapper+Helpers.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ NS_ASSUME_NONNULL_BEGIN
9696
*/
9797
- (nullable NSValue *)fb_hitPoint;
9898

99-
/**
100-
@return YES, if the element type is one that supports placeholder text
101-
*/
102-
- (BOOL)fb_supportsPlaceholder;
103-
10499
@end
105100

106101
NS_ASSUME_NONNULL_END

WebDriverAgentLib/Categories/FBXCElementSnapshotWrapper+Helpers.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,6 @@ - (NSValue *)fb_hitPoint
162162
return [NSValue valueWithCGPoint:result.hitPoint];
163163
}
164164

165-
- (BOOL)fb_supportsPlaceholder {
166-
XCUIElementType elementType = self.elementType;
167-
return elementType == XCUIElementTypeTextField
168-
|| elementType == XCUIElementTypeSearchField
169-
|| elementType == XCUIElementTypeSecureTextField;
170-
}
171-
172165
@end
173166

174167
inline static BOOL isSnapshotTypeAmongstGivenTypes(id<FBXCElementSnapshot> snapshot, NSArray<NSNumber *> *types)

WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#import "XCUIElement+FBUtilities.h"
3838
#import "XCUIElement+FBWebDriverAttributes.h"
3939
#import "XCUIElementQuery.h"
40+
#import "FBElementHelpers.h"
4041

4142
static NSString* const FBUnknownBundleId = @"unknown";
4243

@@ -202,7 +203,7 @@ + (NSDictionary *)dictionaryForElement:(id<FBXCElementSnapshot>)snapshot
202203
info[@"label"] = FBValueOrNull(wrappedSnapshot.wdLabel);
203204
info[@"rect"] = wrappedSnapshot.wdRect;
204205

205-
NSMutableDictionary<NSString *, NSString *(^)(void)> *attributeBlocks = [self attributeBlockMapForSnapshot:snapshot
206+
NSDictionary<NSString *, NSString *(^)(void)> *attributeBlocks = [self fb_attributeBlockMapForSnapshot:snapshot
206207
wrappedSnapshot:wrappedSnapshot];
207208

208209
NSSet *nonPrefixedKeys = [NSSet setWithObjects:FBExclusionAttributeFrame,
@@ -237,9 +238,9 @@ + (NSDictionary *)dictionaryForElement:(id<FBXCElementSnapshot>)snapshot
237238
return info;
238239
}
239240

240-
// Private helper that builds all attribute blocks for a given snapshot.
241-
// Includes both base attributes and any element-specific ones (e.g. placeholder for text inputs, etc.).
242-
+ (NSMutableDictionary<NSString *, NSString *(^)(void)> *)attributeBlockMapForSnapshot:(id<FBXCElementSnapshot>)snapshot
241+
// Helper used by `dictionaryForElement:` to assemble attribute value blocks,
242+
// including both common attributes and conditionally included ones like placeholderValue.
243+
+ (NSDictionary<NSString *, NSString *(^)(void)> *)fb_attributeBlockMapForSnapshot:(id<FBXCElementSnapshot>)snapshot
243244
wrappedSnapshot:(FBXCElementSnapshotWrapper *)wrappedSnapshot
244245
{
245246
// Base attributes common to every element
@@ -262,14 +263,16 @@ + (NSDictionary *)dictionaryForElement:(id<FBXCElementSnapshot>)snapshot
262263
}
263264
} mutableCopy];
264265

266+
XCUIElementType elementType = wrappedSnapshot.elementType;
267+
265268
// Text-input placeholder (only for elements that support inner text)
266-
if ([wrappedSnapshot fb_supportsPlaceholder]) {
269+
if (FBDoesElementSupportInnerText(elementType)) {
267270
blocks[FBExclusionAttributePlaceholderValue] = ^{
268271
return (NSString *)FBValueOrNull(wrappedSnapshot.wdPlaceholderValue);
269272
};
270273
}
271274

272-
return blocks;
275+
return [blocks copy];
273276
}
274277

275278
+ (NSDictionary *)accessibilityInfoForElement:(id<FBXCElementSnapshot>)snapshot

0 commit comments

Comments
 (0)