Class MobileAccessibilityTreeConverter

java.lang.Object
com.shaft.gui.internal.aria.MobileAccessibilityTreeConverter

public final class MobileAccessibilityTreeConverter extends Object
Converts Appium accessibility XML (UiAutomator2 hierarchy/node trees, or XCUITest XCUIElementType* trees) into the AriaNode forest consumed by AriaSnapshotHelper, so matchesAriaSnapshot() baselines work the same way for native mobile as for web.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    captureAriaSnapshot(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By locator)
    Captures an aria snapshot of the element matched by locator on a mobile-native session: reads the element's outerXML attribute (Appium UiAutomator2/XCUITest subtree XML), falling back to the full WebDriver.getPageSource() when outerXML is unavailable, then converts and serializes it.
    static List<AriaNode>
    convert(String pageSourceXml)
    Converts Appium accessibility XML (either a full page source or a single element's outerXML subtree) into an AriaNode forest.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • convert

      public static List<AriaNode> convert(String pageSourceXml)
      Converts Appium accessibility XML (either a full page source or a single element's outerXML subtree) into an AriaNode forest.

      The synthetic Android root wrapper tag hierarchy is skipped; its children become the top-level forest. Nameless generic-container nodes (e.g. FrameLayout, LinearLayout, XCUIElementTypeOther, XCUIElementTypeWindow) are dropped and their children hoisted up in their place; a nameless generic container with no children is dropped entirely. Every other node is kept, whether or not it has a name.

      Parameters:
      pageSourceXml - the Appium accessibility XML to convert
      Returns:
      the converted top-level nodes
      Throws:
      IllegalArgumentException - if pageSourceXml is blank or is not well-formed XML
    • captureAriaSnapshot

      public static String captureAriaSnapshot(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By locator)
      Captures an aria snapshot of the element matched by locator on a mobile-native session: reads the element's outerXML attribute (Appium UiAutomator2/XCUITest subtree XML), falling back to the full WebDriver.getPageSource() when outerXML is unavailable, then converts and serializes it.
      Parameters:
      driver - active mobile-native WebDriver instance
      locator - locator of the element to snapshot
      Returns:
      the captured snapshot serialized as YAML