@@ -202,7 +202,8 @@ + (NSDictionary *)dictionaryForElement:(id<FBXCElementSnapshot>)snapshot
202202 info[@" label" ] = FBValueOrNull (wrappedSnapshot.wdLabel );
203203 info[@" rect" ] = wrappedSnapshot.wdRect ;
204204
205- NSDictionary <NSString *, NSString * (^)(void )> *attributeBlocks = @{
205+ // Define the base attribute blocks that apply to all elements.
206+ NSDictionary <NSString *, NSString * (^)(void )> *baseAttributeBlocks = @{
206207 FBExclusionAttributeFrame: ^{
207208 return NSStringFromCGRect(wrappedSnapshot.wdFrame );
208209 },
@@ -217,11 +218,28 @@ + (NSDictionary *)dictionaryForElement:(id<FBXCElementSnapshot>)snapshot
217218 },
218219 FBExclusionAttributeFocused: ^{
219220 return [@([wrappedSnapshot isWDFocused ]) stringValue ];
220- },
221- FBExclusionAttributePlaceholderValue: ^{
222- return FBValueOrNull (wrappedSnapshot.wdPlaceholderValue );
223221 }
224222 };
223+
224+ NSMutableDictionary <NSString *, NSString *(^)(void )> *attributeBlocks;
225+
226+ // Add placeholderValue only for elements where it is meaningful (e.g., text input fields).
227+ switch (snapshot.elementType ) {
228+ case XCUIElementTypeTextField:
229+ case XCUIElementTypeSecureTextField:
230+ case XCUIElementTypeSearchField: {
231+ // Copy base attributes to a mutable dictionary so we can add placeholderValue.
232+ attributeBlocks = [baseAttributeBlocks mutableCopy ];
233+ attributeBlocks[FBExclusionAttributePlaceholderValue] = ^{
234+ return (NSString *)FBValueOrNull (wrappedSnapshot.wdPlaceholderValue );
235+ };
236+ break ;
237+ }
238+ default :
239+ // Use the base attributes as-is if placeholderValue is not applicable.
240+ attributeBlocks = [baseAttributeBlocks copy ];
241+ break ;
242+ }
225243
226244 NSSet *nonPrefixedKeys = [NSSet setWithObjects: FBExclusionAttributeFrame, FBExclusionAttributePlaceholderValue, nil ];
227245
0 commit comments