Class InputField
java.lang.Object
net.serenitybdd.screenplay.playwright.ui.InputField
Factory for locating input field elements using Playwright selectors.
Supports various strategies for locating text inputs, including by name/id, placeholder, label association, and aria-label.
Sample usage:
Target emailField = InputField.withNameOrId("email");
Target searchField = InputField.withPlaceholder("Search...");
Target usernameField = InputField.withLabel("Username");
Target passwordField = InputField.withAriaLabel("Enter password");
-
Method Summary
Modifier and TypeMethodDescriptionstatic TargetLocate an input field using a custom Playwright selector.static TargetwithAriaLabel(String label) Locate an input field by its aria-label attribute (case-insensitive).static TargetLocate an input field by its associated label text.static TargetwithNameOrId(String name) Locate an input field by its name attribute, id, or data-test attribute.static TargetwithPlaceholder(String text) Locate an input field by its placeholder text (case-insensitive).
-
Method Details
-
withNameOrId
Locate an input field by its name attribute, id, or data-test attribute.- Parameters:
name- The name, id, or data-test value- Returns:
- A Target for the input element
-
withPlaceholder
Locate an input field by its placeholder text (case-insensitive).- Parameters:
text- The placeholder text- Returns:
- A Target for the input element
-
withLabel
Locate an input field by its associated label text. Supports both label elements with for attribute and aria-label.- Parameters:
label- The label text or aria-label value- Returns:
- A Target for the input element
-
withAriaLabel
Locate an input field by its aria-label attribute (case-insensitive).- Parameters:
label- The aria-label value- Returns:
- A Target for the input element
-
locatedBy
Locate an input field using a custom Playwright selector.- Parameters:
selector- A valid Playwright selector- Returns:
- A Target for the input element
-