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
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
aria-label attribute value.
Returns: The value of the aria-label attribute, or null if not present
assertAriaLabel
aria-label attribute matches the expected text. When null is passed, asserts that the aria-label attribute is absent.
The expected aria-label value, or null to assert the attribute is absent
Implementation Details
This interface extendsHasLocatorElement and provides default implementations for all methods.
The assertAriaLabel() method behavior:
- When a value is provided: asserts the
aria-labelattribute matches exactly - When
nullis passed: asserts thearia-labelattribute is not present on the element
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
ButtonElementCheckboxElementRadioButtonElement
Selection Components
ComboBoxElementMultiSelectComboBoxElementSelectElementListBoxElement
Navigation & Menu Components
MenuBarElementMenuElementMenuItemElement
Other Components
PopoverElement
Usage Example
Accessibility Testing Example
Testing Icon-Only Buttons
See Also
- ARIA Label - MDN Web Docs
- ButtonElement - Example implementation with ARIA support
- Web Accessibility Guidelines