Skip to main content

Overview

HasAriaLabelElement is a mixin interface for Vaadin components that expose an ARIA label attribute. This interface provides methods to retrieve and assert aria-label attributes for accessibility testing.

Methods

getAriaLabelLocator

Returns the locator where the aria-label attribute is applied. By default, this returns the component’s root locator. Returns: The locator for the element containing the aria-label attribute (defaults to root)

getAriaLabel

Gets the current aria-label attribute value. Returns: The value of the aria-label attribute, or null if not present

assertAriaLabel

Asserts that the aria-label attribute matches the expected text. When null is passed, asserts that the aria-label attribute is absent.
String
The expected aria-label value, or null to assert the attribute is absent

Implementation Details

This interface extends HasLocatorElement and provides default implementations for all methods. The assertAriaLabel() method behavior:
  • When a value is provided: asserts the aria-label attribute matches exactly
  • When null is passed: asserts the aria-label attribute is not present on the element
The getAriaLabelLocator() method can be overridden by implementing classes if the aria-label is applied to a child element rather than the root.

Implementing Classes

This interface is implemented by:

Interactive Components

  • ButtonElement
  • CheckboxElement
  • RadioButtonElement

Selection Components

  • ComboBoxElement
  • MultiSelectComboBoxElement
  • SelectElement
  • ListBoxElement
  • MenuBarElement
  • MenuElement
  • MenuItemElement

Other Components

  • PopoverElement

Usage Example

Accessibility Testing Example

Testing Icon-Only Buttons

See Also