Skip to main content

Hierarchy API

Description

IDroidHierarchyAPI provides access to the UI element tree of the current device screen. Used to retrieve the UI structure as an XML tree of all elements and their relationships.


Methods

GetLayout

  • string GetLayout()
    Returns the XML tree of the current screen with the full UI element hierarchy and element attributes (bounds, text, resource-id, class, etc.). The XML is post-processed: fully-qualified Java package prefixes are stripped from element tag names, so node names stay short and human-readable (e.g. android.widget.TextView becomes TextView). To get the unprocessed XML, use AppiumDriver.GetRawSource().

    Returns:
    An XML string with the UI element hierarchy (with package-name prefixes removed from tag names).

Example

var xml = instance.DroidInstance.Hierarchy.GetLayout(); // Get the current device screen XML