Overview
HasValidationPropertiesElement provides methods for interacting with Vaadin components that support validation states and error messages. It allows you to check whether a component is valid or invalid, and to assert the presence and content of error messages.
Interface Location: org.vaadin.addons.dramafinder.element.shared.HasValidationPropertiesElement
Methods
getErrorMessageLocator()
Locator - Locator for the element with slot="error-message"
assertValid()
invalid attribute).
Throws: AssertionError if the component has the invalid attribute
assertInvalid()
invalid attribute).
Throws: AssertionError if the component does not have the invalid attribute
assertErrorMessage()
The expected error message text
AssertionError if the error message does not match
Implementing Classes
The following element classes implementHasValidationPropertiesElement:
TextFieldElement(and its subclasses)AbstractNumberFieldElement(and its subclasses)DatePickerElementDateTimePickerElementTimePickerElementRadioButtonGroupElement
Usage Example
Implementation Details
Error Message Slot
Vaadin components use a slot-based architecture for error messages. ThegetErrorMessageLocator() method targets elements with slot="error-message", which is where Vaadin renders validation error messages in the shadow DOM.
Validation Attribute
Vaadin components indicate validation state through theinvalid HTML attribute. When a component fails validation, the invalid attribute is set to an empty string (invalid=""). The assertValid() and assertInvalid() methods check for the presence or absence of this attribute.
Testing Patterns
Validation After User Input
Server-Side Validation
Required Field Validation
Related Interfaces
- HasInputFieldElement - Often composed with validation capabilities
- FocusableElement - Used to trigger validation via blur events