Class AriaSnapshotHelper

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

public final class AriaSnapshotHelper extends Object
Captures and compares accessible-name-tree ("aria") snapshots: a pragmatic, DOM-walk-based subset of ARIA role/name resolution (not full ARIA AAM spec compliance), serialized as a strict subset of Playwright's aria snapshot YAML DSL (no [level=n] attributes, no regex names).

Both backends run the same ariaSnapshot.js DOM walk so web output is directly comparable.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Result of a partial-subset aria snapshot comparison.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    captureAriaSnapshot(com.microsoft.playwright.Locator locator)
    Captures an aria snapshot of the element matched by locator, using Playwright JavaScript evaluation.
    static String
    captureAriaSnapshot(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By locator)
    Captures an aria snapshot of the element matched by locator, using Selenium JavaScript execution.
    match(String baselineYaml, String actualYaml)
    Performs a partial-subset structural match: every baseline node must match an actual node at the same depth, in order (role equal; name equal after trim, or the baseline name may be blank to match any actual name); extra actual siblings/children are allowed.
    static List<AriaNode>
    parse(String yaml)
    Parses SHAFT's aria snapshot YAML format back into an accessible-name-tree forest.
    static String
    Serializes an accessible-name-tree forest to SHAFT's aria snapshot YAML format.

    Methods inherited from class Object

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

    • 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, using Selenium JavaScript execution.
      Parameters:
      driver - active WebDriver instance (must support JavascriptExecutor)
      locator - locator of the element to snapshot
      Returns:
      the captured snapshot serialized as YAML
    • captureAriaSnapshot

      public static String captureAriaSnapshot(com.microsoft.playwright.Locator locator)
      Captures an aria snapshot of the element matched by locator, using Playwright JavaScript evaluation.
      Parameters:
      locator - Playwright locator of the element to snapshot
      Returns:
      the captured snapshot serialized as YAML
    • serialize

      public static String serialize(List<AriaNode> forest)
      Serializes an accessible-name-tree forest to SHAFT's aria snapshot YAML format.
      Parameters:
      forest - the top-level nodes to serialize
      Returns:
      the YAML representation
    • parse

      public static List<AriaNode> parse(String yaml)
      Parses SHAFT's aria snapshot YAML format back into an accessible-name-tree forest.
      Parameters:
      yaml - the YAML representation
      Returns:
      the parsed top-level nodes, or an empty list for blank input
    • match

      public static AriaSnapshotHelper.AriaMatchResult match(String baselineYaml, String actualYaml)
      Performs a partial-subset structural match: every baseline node must match an actual node at the same depth, in order (role equal; name equal after trim, or the baseline name may be blank to match any actual name); extra actual siblings/children are allowed. This is a pragmatic (greedy, not fully backtracking) subsequence match, sufficient for visual/structural regression baselining.
      Parameters:
      baselineYaml - the stored baseline snapshot
      actualYaml - the freshly captured snapshot
      Returns:
      the match result, with a readable diff message on mismatch