java.lang.Object
net.serenitybdd.screenplay.playwright.questions.AccessibilitySnapshot
All Implemented Interfaces:
net.serenitybdd.screenplay.Question<String>

public class AccessibilitySnapshot extends Object implements net.serenitybdd.screenplay.Question<String>
Retrieve accessibility information from the page or a specific element.

This question provides accessibility details using Playwright's ARIA snapshot functionality, which is useful for testing accessibility compliance.

Sample usage:

     // Get accessibility info for the entire page
     String snapshot = actor.asksFor(AccessibilitySnapshot.ofThePage());

     // Get accessibility info for a specific element
     String snapshot = actor.asksFor(AccessibilitySnapshot.of("#main-nav"));
     String snapshot = actor.asksFor(AccessibilitySnapshot.of(NAVIGATION));

     // Get all elements with a specific ARIA role
     List<String> buttons = actor.asksFor(AccessibilitySnapshot.allWithRole(AriaRole.BUTTON));
 
See Also:
  • Method Details

    • ofThePage

      public static AccessibilitySnapshot ofThePage()
      Get the accessibility snapshot of the entire page. Returns a YAML-like representation of the accessibility tree.
    • of

      public static AccessibilitySnapshot of(String selector)
      Get the accessibility snapshot of a specific element.
      Parameters:
      selector - The CSS or XPath selector for the element
    • of

      public static AccessibilitySnapshot of(Target target)
      Get the accessibility snapshot of a specific Target element.
      Parameters:
      target - The Target element
    • allWithRole

      public static net.serenitybdd.screenplay.Question<List<String>> allWithRole(com.microsoft.playwright.options.AriaRole role)
      Get all elements with the specified ARIA role.
      Parameters:
      role - The ARIA role to search for
      Returns:
      A Question that returns a list of accessible names for elements with the role
    • answeredBy

      public String answeredBy(net.serenitybdd.screenplay.Actor actor)
      Specified by:
      answeredBy in interface net.serenitybdd.screenplay.Question<String>
    • toString

      public String toString()
      Overrides:
      toString in class Object