Class Label
java.lang.Object
net.serenitybdd.screenplay.playwright.ui.Label
Factory for locating label elements using Playwright selectors.
Useful for finding labels associated with form fields or as standalone text elements.
Sample usage:
Target usernameLabel = Label.withText("Username");
Target exactLabel = Label.withExactText("Email Address");
Target emailLabel = Label.forFieldId("email");
-
Method Summary
Modifier and TypeMethodDescriptionstatic TargetforFieldId(String fieldId) Locate a label by its 'for' attribute (field association).static TargetLocate a label using a custom Playwright selector.static TargetwithExactText(String text) Locate a label with exact text content.static TargetLocate a label containing the specified text (partial match).
-
Method Details
-
withText
Locate a label containing the specified text (partial match).- Parameters:
text- The text to search for within the label- Returns:
- A Target for the label element
-
withExactText
Locate a label with exact text content.- Parameters:
text- The exact text content- Returns:
- A Target for the label element
-
forFieldId
Locate a label by its 'for' attribute (field association).- Parameters:
fieldId- The id of the associated form field- Returns:
- A Target for the label element
-
locatedBy
Locate a label using a custom Playwright selector.- Parameters:
selector- A valid Playwright selector- Returns:
- A Target for the label element
-