Overview
HasPrefixElement provides utilities to interact with Vaadin components that implement the HasPrefix interface, which allows placing content in a prefix slot. The prefix typically appears at the start of the component, before the main input or content area.
This mixin interface extends HasLocatorElement and provides default implementations for accessing, reading, and asserting prefix slot content.
Interface
Methods
getPrefixLocator()
Returns a locator for the prefix slot content.Locator targeting the first element with slot="prefix"
Implementation:
getPrefixText()
Retrieves the text content of the prefix slot.assertPrefixHasText()
Asserts that the prefix slot has the expected text, or is hidden when null.String
Expected text content of the prefix. If
null, asserts that the prefix is not visible.- If
textis non-null: Asserts the prefix has exactly that text - If
textis null: Asserts the prefix is not visible
Implementing Classes
The following element classes implementHasPrefixElement:
TextFieldElement- Text input fieldsBigDecimalFieldElement- Decimal number fieldsAbstractNumberFieldElement- Base class for number fieldsComboBoxElement- Combo box selectorsSelectElement- Select dropdownsButtonElement- Action buttonsSideNavigationItemElement- Navigation items
Usage Examples
Basic Prefix Access
Custom Prefix Interactions
Asserting Prefix Visibility
Integration Test Example
Related Interfaces
- HasLocatorElement - Parent interface
- HasSuffixElement - Companion interface for suffix slot content
Vaadin Documentation
For more information about the VaadinHasPrefix interface, see the Vaadin Components documentation.