Skip to main content

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.
Returns: Locator targeting the first element with slot="prefix" Implementation:

getPrefixText()

Retrieves the text content of the prefix slot.
Returns: The text content of the prefix element

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.
Behavior:
  • If text is non-null: Asserts the prefix has exactly that text
  • If text is null: Asserts the prefix is not visible

Implementing Classes

The following element classes implement HasPrefixElement:
  • TextFieldElement - Text input fields
  • BigDecimalFieldElement - Decimal number fields
  • AbstractNumberFieldElement - Base class for number fields
  • ComboBoxElement - Combo box selectors
  • SelectElement - Select dropdowns
  • ButtonElement - Action buttons
  • SideNavigationItemElement - Navigation items

Usage Examples

Basic Prefix Access

Custom Prefix Interactions

Asserting Prefix Visibility

Integration Test Example

Vaadin Documentation

For more information about the Vaadin HasPrefix interface, see the Vaadin Components documentation.