appium-webdriveragent 8.10.1 → 8.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [8.11.1](https://github.com/appium/WebDriverAgent/compare/v8.11.0...v8.11.1) (2024-11-11)
2
+
3
+ ### Miscellaneous Chores
4
+
5
+ * bump appium-ios-device ([#955](https://github.com/appium/WebDriverAgent/issues/955)) ([021f349](https://github.com/appium/WebDriverAgent/commit/021f34901866f4a7870914c00781b83bd0cbddc4))
6
+
7
+ ## [8.11.0](https://github.com/appium/WebDriverAgent/compare/v8.10.1...v8.11.0) (2024-11-11)
8
+
9
+ ### Features
10
+
11
+ * Add support for excluded_attributes in JSON source hierarchy ([#953](https://github.com/appium/WebDriverAgent/issues/953)) ([6112223](https://github.com/appium/WebDriverAgent/commit/6112223b21026fae5545fe1b1433a09c67ff524b))
12
+
1
13
  ## [8.10.1](https://github.com/appium/WebDriverAgent/compare/v8.10.0...v8.10.1) (2024-11-10)
2
14
 
3
15
  ### Miscellaneous Chores
@@ -31,6 +31,12 @@ NS_ASSUME_NONNULL_BEGIN
31
31
  */
32
32
  - (NSDictionary *)fb_tree;
33
33
 
34
+ /**
35
+ @param excludedAttributes Set of possible attributes to be excluded i.e frame, enabled, visible, accessible, focused. If set to nil or an empty array then no attributes will be excluded from the resulting JSON
36
+ @return application elements tree in form of nested dictionaries
37
+ */
38
+ - (NSDictionary *)fb_tree:(nullable NSSet<NSString *> *) excludedAttributes;
39
+
34
40
  /**
35
41
  Return application elements accessibility tree in form of nested dictionaries
36
42
  */
@@ -152,11 +152,16 @@ NSDictionary<NSNumber *, NSString *> *auditTypeValuesToNames(void) {
152
152
  }
153
153
 
154
154
  - (NSDictionary *)fb_tree
155
+ {
156
+ return [self fb_tree:nil];
157
+ }
158
+
159
+ - (NSDictionary *)fb_tree:(nullable NSSet<NSString *> *) excludedAttributes
155
160
  {
156
161
  id<FBXCElementSnapshot> snapshot = self.fb_isResolvedFromCache.boolValue
157
162
  ? self.lastSnapshot
158
163
  : [self fb_snapshotWithAllAttributesAndMaxDepth:nil];
159
- return [self.class dictionaryForElement:snapshot recursive:YES];
164
+ return [self.class dictionaryForElement:snapshot recursive:YES excludedAttributes:excludedAttributes];
160
165
  }
161
166
 
162
167
  - (NSDictionary *)fb_accessibilityTree
@@ -167,7 +172,9 @@ NSDictionary<NSNumber *, NSString *> *auditTypeValuesToNames(void) {
167
172
  return [self.class accessibilityInfoForElement:snapshot];
168
173
  }
169
174
 
170
- + (NSDictionary *)dictionaryForElement:(id<FBXCElementSnapshot>)snapshot recursive:(BOOL)recursive
175
+ + (NSDictionary *)dictionaryForElement:(id<FBXCElementSnapshot>)snapshot
176
+ recursive:(BOOL)recursive
177
+ excludedAttributes:(nullable NSSet<NSString *> *) excludedAttributes
171
178
  {
172
179
  NSMutableDictionary *info = [[NSMutableDictionary alloc] init];
173
180
  info[@"type"] = [FBElementTypeTransformer shortStringWithElementType:snapshot.elementType];
@@ -177,11 +184,35 @@ NSDictionary<NSNumber *, NSString *> *auditTypeValuesToNames(void) {
177
184
  info[@"value"] = FBValueOrNull(wrappedSnapshot.wdValue);
178
185
  info[@"label"] = FBValueOrNull(wrappedSnapshot.wdLabel);
179
186
  info[@"rect"] = wrappedSnapshot.wdRect;
180
- info[@"frame"] = NSStringFromCGRect(wrappedSnapshot.wdFrame);
181
- info[@"isEnabled"] = [@([wrappedSnapshot isWDEnabled]) stringValue];
182
- info[@"isVisible"] = [@([wrappedSnapshot isWDVisible]) stringValue];
183
- info[@"isAccessible"] = [@([wrappedSnapshot isWDAccessible]) stringValue];
184
- info[@"isFocused"] = [@([wrappedSnapshot isWDFocused]) stringValue];
187
+
188
+ NSDictionary<NSString *, NSString * (^)(void)> *attributeBlocks = @{
189
+ @"frame": ^{
190
+ return NSStringFromCGRect(wrappedSnapshot.wdFrame);
191
+ },
192
+ @"enabled": ^{
193
+ return [@([wrappedSnapshot isWDEnabled]) stringValue];
194
+ },
195
+ @"visible": ^{
196
+ return [@([wrappedSnapshot isWDVisible]) stringValue];
197
+ },
198
+ @"accessible": ^{
199
+ return [@([wrappedSnapshot isWDAccessible]) stringValue];
200
+ },
201
+ @"focused": ^{
202
+ return [@([wrappedSnapshot isWDFocused]) stringValue];
203
+ }
204
+ };
205
+
206
+ for (NSString *key in attributeBlocks) {
207
+ if (excludedAttributes == nil || ![excludedAttributes containsObject:key]) {
208
+ NSString *value = ((NSString * (^)(void))attributeBlocks[key])();
209
+ if ([key isEqualToString:@"frame"]) {
210
+ info[key] = value;
211
+ } else {
212
+ info[[NSString stringWithFormat:@"is%@", [key capitalizedString]]] = value;
213
+ }
214
+ }
215
+ }
185
216
 
186
217
  if (!recursive) {
187
218
  return info.copy;
@@ -191,7 +222,9 @@ NSDictionary<NSNumber *, NSString *> *auditTypeValuesToNames(void) {
191
222
  if ([childElements count]) {
192
223
  info[@"children"] = [[NSMutableArray alloc] init];
193
224
  for (id<FBXCElementSnapshot> childSnapshot in childElements) {
194
- [info[@"children"] addObject:[self dictionaryForElement:childSnapshot recursive:YES]];
225
+ [info[@"children"] addObject:[self dictionaryForElement:childSnapshot
226
+ recursive:YES
227
+ excludedAttributes:excludedAttributes]];
195
228
  }
196
229
  }
197
230
  return info;
@@ -379,7 +412,9 @@ NSDictionary<NSNumber *, NSString *> *auditTypeValuesToNames(void) {
379
412
  id extractedElement = extractIssueProperty(issue, @"element");
380
413
 
381
414
  id<FBXCElementSnapshot> elementSnapshot = [extractedElement fb_takeSnapshot];
382
- NSDictionary *elementAttributes = elementSnapshot ? [self.class dictionaryForElement:elementSnapshot recursive:NO] : @{};
415
+ NSDictionary *elementAttributes = elementSnapshot
416
+ ? [self.class dictionaryForElement:elementSnapshot recursive:NO excludedAttributes:nil]
417
+ : @{};
383
418
 
384
419
  [resultArray addObject:@{
385
420
  @"detailedDescription": extractIssueProperty(issue, @"detailedDescription") ?: @"",
@@ -54,7 +54,12 @@ static NSString *const SOURCE_FORMAT_DESCRIPTION = @"description";
54
54
  withExcludedAttributes:excludedAttributes]
55
55
  withScope:sourceScope]];
56
56
  } else if ([sourceType caseInsensitiveCompare:SOURCE_FORMAT_JSON] == NSOrderedSame) {
57
- result = application.fb_tree;
57
+ NSString *excludedAttributesString = request.parameters[@"excluded_attributes"];
58
+ NSSet<NSString *> *excludedAttributes = (excludedAttributesString == nil)
59
+ ? nil
60
+ : [NSSet setWithArray:[excludedAttributesString componentsSeparatedByString:@","]];
61
+
62
+ result = [application fb_tree:excludedAttributes];
58
63
  } else if ([sourceType caseInsensitiveCompare:SOURCE_FORMAT_DESCRIPTION] == NSOrderedSame) {
59
64
  result = application.fb_descriptionRepresentation;
60
65
  } else {
@@ -15,11 +15,11 @@
15
15
  <key>CFBundlePackageType</key>
16
16
  <string>FMWK</string>
17
17
  <key>CFBundleShortVersionString</key>
18
- <string>8.10.1</string>
18
+ <string>8.11.1</string>
19
19
  <key>CFBundleSignature</key>
20
20
  <string>????</string>
21
21
  <key>CFBundleVersion</key>
22
- <string>8.10.1</string>
22
+ <string>8.11.1</string>
23
23
  <key>NSPrincipalClass</key>
24
24
  <string/>
25
25
  </dict>
@@ -44,6 +44,13 @@
44
44
  XCTAssertNotNil(self.testedApplication.fb_accessibilityTree);
45
45
  }
46
46
 
47
+ - (void)testApplicationTreeAttributesFiltering
48
+ {
49
+ NSDictionary *applicationTree = [self.testedApplication fb_tree:[NSSet setWithArray:@[@"visible"]]];
50
+ XCTAssertNotNil(applicationTree);
51
+ XCTAssertNil([applicationTree objectForKey:@"isVisible"], @"'isVisible' key should not be present in the application tree");
52
+ }
53
+
47
54
  - (void)testDeactivateApplication
48
55
  {
49
56
  NSError *error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "8.10.1",
3
+ "version": "8.11.1",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -76,7 +76,7 @@
76
76
  "@appium/base-driver": "^9.0.0",
77
77
  "@appium/strongbox": "^0.x",
78
78
  "@appium/support": "^5.0.3",
79
- "appium-ios-device": "^2.5.0",
79
+ "appium-ios-device": "^2.7.25",
80
80
  "appium-ios-simulator": "^6.0.0",
81
81
  "async-lock": "^1.0.0",
82
82
  "asyncbox": "^3.0.0",