Skip to main content

Overview

The TextFieldElement class is a Playwright wrapper for the <vaadin-text-field> component. It provides methods to interact with text fields, including setting values, validating input, and accessing field properties.

Component Tag

<vaadin-text-field>

Extends

  • VaadinElement

Implements

  • HasValidationPropertiesElement - Validation state and error messages
  • HasInputFieldElement - Value, label, helper text, and styling
  • HasPrefixElement - Prefix slot content
  • HasSuffixElement - Suffix slot content
  • HasClearButtonElement - Clear button functionality
  • HasPlaceholderElement - Placeholder text
  • HasAllowedCharPatternElement - Character input restrictions
  • HasThemeElement - Theme variants
  • FocusableElement - Focus and blur operations
  • HasAriaLabelElement - ARIA label support
  • HasEnabledElement - Enabled/disabled state
  • HasTooltipElement - Tooltip text

Constructor

Locator
required
The Playwright locator for the <vaadin-text-field> element

Factory Methods

getByLabel (Page)

Get a text field by its accessible label. Uses ARIA role textbox.
Page
required
The Playwright page
String
required
The accessible label of the text field

Example

getByLabel (Locator)

Get a text field by its accessible label within a scope.
Locator
required
The locator to search within
String
required
The accessible label of the text field

Methods

getMinLength

Get the current minimum length constraint.
Returns: The minimum length or null if not set

setMinLength

Set the minimum length constraint.
int
required
The minimum length

assertMinLength

Assert the minimum length matches the expected value.
Integer
The expected minimum length, or null to assert no minimum is set

Example

getMaxLength

Get the current maximum length constraint.
Returns: The maximum length or null if not set

setMaxLength

Set the maximum length constraint.
int
required
The maximum length

assertMaxLength

Assert the maximum length matches the expected value.
Integer
The expected maximum length, or null to assert no maximum is set

Example

getPattern

Get the current validation pattern.
Returns: The pattern or null if not set

setPattern

Set the validation pattern.
String
required
The regex pattern

assertPattern

Assert the pattern matches the expected value.
String
The expected pattern, or null to assert no pattern is set

Example

getFocusLocator

Get the locator for focus operations. Returns the input locator.

getAriaLabelLocator

Get the locator for ARIA label operations. Returns the input locator.

getEnabledLocator

Get the locator for enabled/disabled state. Returns the input locator.

Inherited Methods

From HasValueElement:
  • getValue() - Get current value
  • setValue(String value) - Set field value
  • clear() - Clear the value
  • assertValue(String value) - Assert value matches
  • getInputLocator() - Get input element locator
From HasValidationPropertiesElement:
  • assertValid() - Assert field is valid
  • assertInvalid() - Assert field is invalid
  • assertErrorMessage(String message) - Assert error message text
  • getErrorMessageLocator() - Get error message locator
From HasClearButtonElement:
  • clickClearButton() - Click the clear button
  • isClearButtonVisible() - Check if clear button is visible
  • assertClearButtonVisible() - Assert clear button is visible
  • assertClearButtonNotVisible() - Assert clear button is not visible
From HasPlaceholderElement:
  • getPlaceholder() - Get placeholder text
  • setPlaceholder(String placeholder) - Set placeholder text
  • assertPlaceholder(String placeholder) - Assert placeholder matches
From FocusableElement:
  • focus() - Focus the field
  • blur() - Blur the field
  • getTabIndex() - Get tab index
  • assertIsFocused() - Assert field has focus
  • assertIsNotFocused() - Assert field does not have focus
From HasLabelElement:
  • getLabel() - Get label text
  • assertLabel(String label) - Assert label text
  • getLabelLocator() - Get label locator
From HasHelperElement:
  • getHelperText() - Get helper text
  • assertHelperHasText(String text) - Assert helper text
  • getHelperLocator() - Get helper locator

Complete Example