Overview
TheTextFieldElement 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 messagesHasInputFieldElement- Value, label, helper text, and stylingHasPrefixElement- Prefix slot contentHasSuffixElement- Suffix slot contentHasClearButtonElement- Clear button functionalityHasPlaceholderElement- Placeholder textHasAllowedCharPatternElement- Character input restrictionsHasThemeElement- Theme variantsFocusableElement- Focus and blur operationsHasAriaLabelElement- ARIA label supportHasEnabledElement- Enabled/disabled stateHasTooltipElement- Tooltip text
Constructor
The Playwright locator for the
<vaadin-text-field> elementFactory Methods
getByLabel (Page)
Get a text field by its accessible label. Uses ARIA roletextbox.
The Playwright page
The accessible label of the text field
Example
getByLabel (Locator)
Get a text field by its accessible label within a scope.The locator to search within
The accessible label of the text field
Methods
getMinLength
Get the current minimum length constraint.null if not set
setMinLength
Set the minimum length constraint.The minimum length
assertMinLength
Assert the minimum length matches the expected value.The expected minimum length, or
null to assert no minimum is setExample
getMaxLength
Get the current maximum length constraint.null if not set
setMaxLength
Set the maximum length constraint.The maximum length
assertMaxLength
Assert the maximum length matches the expected value.The expected maximum length, or
null to assert no maximum is setExample
getPattern
Get the current validation pattern.null if not set
setPattern
Set the validation pattern.The regex pattern
assertPattern
Assert the pattern matches the expected value.The expected pattern, or
null to assert no pattern is setExample
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
FromHasValueElement:
getValue()- Get current valuesetValue(String value)- Set field valueclear()- Clear the valueassertValue(String value)- Assert value matchesgetInputLocator()- Get input element locator
HasValidationPropertiesElement:
assertValid()- Assert field is validassertInvalid()- Assert field is invalidassertErrorMessage(String message)- Assert error message textgetErrorMessageLocator()- Get error message locator
HasClearButtonElement:
clickClearButton()- Click the clear buttonisClearButtonVisible()- Check if clear button is visibleassertClearButtonVisible()- Assert clear button is visibleassertClearButtonNotVisible()- Assert clear button is not visible
HasPlaceholderElement:
getPlaceholder()- Get placeholder textsetPlaceholder(String placeholder)- Set placeholder textassertPlaceholder(String placeholder)- Assert placeholder matches
FocusableElement:
focus()- Focus the fieldblur()- Blur the fieldgetTabIndex()- Get tab indexassertIsFocused()- Assert field has focusassertIsNotFocused()- Assert field does not have focus
HasLabelElement:
getLabel()- Get label textassertLabel(String label)- Assert label textgetLabelLocator()- Get label locator
HasHelperElement:
getHelperText()- Get helper textassertHelperHasText(String text)- Assert helper textgetHelperLocator()- Get helper locator