GREYElementHierarchy

@interface GREYElementHierarchy : NSObject

A utility to get the string representation of the UI hierarchy.

  • Returns UI hierarchy with @c element as the root. @c element can be either a UIView or an Accessibility element.

    Declaration

    Objective-C

    + (NSString *)hierarchyStringForElement:(id)element;

    Swift

    class func hierarchyString(forElement element: Any!) -> String!

    Parameters

    element

    The root element for the hierarchy.

    Return Value

    The UI hierarchy as a string.

  • Similar to hierarchyStringForElement: with additional parameters for providing annotations for printed views. @c annotationDictionary is a dictionary of type @code @{[NSValue valueWithNonretainedObject:id]:NSString} @endcode with UI elements that require special formatting i.e. special text to be appended to the description. For example, @code @{viewA : @This is a special view} @endcode or @code @{elementA : @This is a special view} @endcode will have it’s description as: @ This is a special view.

    Declaration

    Objective-C

    + (NSString *)hierarchyStringForElement:(id)element
                   withAnnotationDictionary:(NSDictionary *)annotationDictionary;

    Swift

    class func hierarchyString(forElement element: Any!, withAnnotationDictionary annotationDictionary: [AnyHashable : Any]!) -> String!

    Parameters

    element

    The root element for the hierarchy.

    annotationDictionary

    A dictionary of annotations.

    Return Value

    The UI hierarchy as a string.

  • Returns the UI hierarchy for all @c UIWindows provided by the GREYUIWindowProvider.

    Declaration

    Objective-C

    + (NSString *)hierarchyStringForAllUIWindows;

    Swift

    class func hierarchyStringForAllUIWindows() -> String!