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

public class InputField extends Object
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 Details

    • withNameOrId

      public static Target withNameOrId(String name)
      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

      public static Target withPlaceholder(String text)
      Locate an input field by its placeholder text (case-insensitive).
      Parameters:
      text - The placeholder text
      Returns:
      A Target for the input element
    • withLabel

      public static Target withLabel(String label)
      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

      public static Target withAriaLabel(String label)
      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

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