Class MobileAccessibilityTreeConverter
java.lang.Object
com.shaft.gui.internal.aria.MobileAccessibilityTreeConverter
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 TypeMethodDescriptionstatic StringcaptureAriaSnapshot(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By locator) Captures an aria snapshot of the element matched bylocatoron a mobile-native session: reads the element'souterXMLattribute (Appium UiAutomator2/XCUITest subtree XML), falling back to the fullWebDriver.getPageSource()whenouterXMLis unavailable, then converts and serializes it.Converts Appium accessibility XML (either a full page source or a single element'souterXMLsubtree) into anAriaNodeforest.
-
Method Details
-
convert
Converts Appium accessibility XML (either a full page source or a single element'souterXMLsubtree) into anAriaNodeforest.The synthetic Android root wrapper tag
hierarchyis 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- ifpageSourceXmlis 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 bylocatoron a mobile-native session: reads the element'souterXMLattribute (Appium UiAutomator2/XCUITest subtree XML), falling back to the fullWebDriver.getPageSource()whenouterXMLis unavailable, then converts and serializes it.- Parameters:
driver- active mobile-native WebDriver instancelocator- locator of the element to snapshot- Returns:
- the captured snapshot serialized as YAML
-