[XCTest][iOS][Appium] Get all of elements in XCUIElementQuery

I posted [Appium][xcuitest]Compare getting outputs speed of source format before. Today, I would like to dive a bit more.

The description shows debugDescription of available elements. So, how to get the available elements ?

That is allElementsBoundByAccessibilityElement

Immediately evaluates the query and returns an array of elements bound to the resulting accessibility elements.

In fb_descriptionRepresentation, it used as below. Then, all of available debugDescription return to the client.

- (NSString *)fb_descriptionRepresentation
{
  NSMutableArray<NSString *> *childrenDescriptions = [NSMutableArray array];
  for (XCUIElement *child in [self childrenMatchingType:XCUIElementTypeAny].allElementsBoundByAccessibilityElement) {
    [childrenDescriptions addObject:child.debugDescription];
  }
  // debugDescription property of XCUIApplication instance shows descendants addresses in memory
  // instead of the actual information about them, however the representation works properly
  // for all descendant elements
  return (0 == childrenDescriptions.count) ? self.debugDescription : [childrenDescriptions componentsJoinedByString:@"\n\n"];
}

https://github.com/appium/WebDriverAgent/blob/master/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m#L147-L157

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.