java.lang.Object
net.serenitybdd.screenplay.playwright.ui.Button

public class Button extends Object
Factory for locating button elements using Playwright selectors.

Uses Playwright's powerful selector syntax including role selectors for accessibility-aware element location.

Sample usage:

     Target submitButton = Button.withText("Submit");
     Target loginButton = Button.withNameOrId("login-btn");
     Target saveButton = Button.withAriaLabel("Save changes");
     Target actionButton = Button.containingText("Action");
 
See Also:
  • Method Details

    • withText

      public static Target withText(String text)
      Locate a button by its exact accessible name (case-insensitive). Uses Playwright's role selector for semantic button matching.
      Parameters:
      text - The button's accessible name or text content
      Returns:
      A Target for the button element
    • withNameOrId

      public static Target withNameOrId(String name)
      Locate a button by its name attribute, id, or data-test attribute.
      Parameters:
      name - The name, id, or data-test value
      Returns:
      A Target for the button element
    • withAriaLabel

      public static Target withAriaLabel(String label)
      Locate a button by its aria-label attribute (case-insensitive).
      Parameters:
      label - The aria-label value
      Returns:
      A Target for the button element
    • containingText

      public static Target containingText(String text)
      Locate a button containing the specified text (partial match).
      Parameters:
      text - The text to search for within the button
      Returns:
      A Target for the button element
    • locatedBy

      public static Target locatedBy(String selector)
      Locate a button using a custom Playwright selector.
      Parameters:
      selector - A valid Playwright selector
      Returns:
      A Target for the button element