Class Button
java.lang.Object
net.serenitybdd.screenplay.playwright.ui.Button
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 Summary
Modifier and TypeMethodDescriptionstatic TargetcontainingText(String text) Locate a button containing the specified text (partial match).static TargetLocate a button using a custom Playwright selector.static TargetwithAriaLabel(String label) Locate a button by its aria-label attribute (case-insensitive).static TargetwithNameOrId(String name) Locate a button by its name attribute, id, or data-test attribute.static TargetLocate a button by its exact accessible name (case-insensitive).
-
Method Details
-
withText
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
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
Locate a button by its aria-label attribute (case-insensitive).- Parameters:
label- The aria-label value- Returns:
- A Target for the button element
-
containingText
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
Locate a button using a custom Playwright selector.- Parameters:
selector- A valid Playwright selector- Returns:
- A Target for the button element
-