From 0d7e4a697adb7355279583eaa05118f396056e6f Mon Sep 17 00:00:00 2001 From: Ilya Kharebashvili Date: Thu, 16 Nov 2023 12:26:43 +0200 Subject: [PATCH] feat: Add element attributes to the performAccessibilityAudit output (#808) --- .../Categories/XCUIApplication+FBHelpers.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m b/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m index 4faaed1ae..2656de7d6 100644 --- a/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +++ b/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m @@ -369,12 +369,19 @@ - (BOOL)fb_dismissKeyboardWithKeyNames:(nullable NSArray *)keyNames if (nil != auditTypeValue) { auditType = valuesToNamesMap[auditTypeValue] ?: [auditTypeValue stringValue]; } + + id extractedElement = extractIssueProperty(issue, @"element"); + + id elementSnapshot = [extractedElement fb_takeSnapshot]; + NSDictionary *elementAttributes = elementSnapshot ? [self.class dictionaryForElement:elementSnapshot recursive:NO] : @{}; + [resultArray addObject:@{ @"detailedDescription": extractIssueProperty(issue, @"detailedDescription") ?: @"", @"compactDescription": extractIssueProperty(issue, @"compactDescription") ?: @"", @"auditType": auditType, - @"element": [extractIssueProperty(issue, @"element") description] ?: @"", - @"elementDescription": [extractIssueProperty(issue, @"element") debugDescription] ?: @"", + @"element": [extractedElement description] ?: @"", + @"elementDescription": [extractedElement debugDescription] ?: @"", + @"elementAttributes": elementAttributes ?: @{}, }]; return YES; };