Overview
HasEnabledElement provides methods for checking and asserting the enabled/disabled state of Vaadin components. This interface is essential for testing interactive components that can be enabled or disabled based on application logic.
Interface Location: org.vaadin.addons.dramafinder.element.shared.HasEnabledElement
Methods
getEnabledLocator()
Locator - The locator to check for enabled/disabled state
isEnabled()
boolean - true if the component is enabled, false if disabled
assertEnabled()
AssertionError if the component is disabled
assertDisabled()
AssertionError if the component is enabled
Implementing Classes
The following element classes implementHasEnabledElement:
ButtonElementCheckboxElementRadioButtonElementRadioButtonGroupElementMessageInputElementGridElementUploadElementSideNavigationItemElement- All text field components (via
TextFieldElementand its subclasses)
Usage Example
Implementation Details
Locator Delegation Pattern
Some components overridegetEnabledLocator() to target a specific internal element rather than the component root. For example, text field components delegate to their input element:
Playwright’s isEnabled()
TheisEnabled() method uses Playwright’s built-in Locator.isEnabled(), which checks whether an element:
- Does not have the
disabledattribute - Is not a disabled fieldset ancestor
- Is not hidden or detached from the DOM
Testing Patterns
Conditional Button Enabling
Disabled Form Fields
Dynamic State Changes
Related Interfaces
- FocusableElement - Components that can be enabled/disabled are often focusable
- HasInputFieldElement - Input fields typically support enabled/disabled state