Skip to main content

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()

Returns the locator used to check enablement state. By default, returns the root component locator, but implementations may override this to target a specific internal element (e.g., an input field within a component). Returns: Locator - The locator to check for enabled/disabled state

isEnabled()

Checks whether the component is currently enabled. Returns: boolean - true if the component is enabled, false if disabled

assertEnabled()

Asserts that the component is enabled. Throws: AssertionError if the component is disabled

assertDisabled()

Asserts that the component is disabled. Throws: AssertionError if the component is enabled

Implementing Classes

The following element classes implement HasEnabledElement:
  • ButtonElement
  • CheckboxElement
  • RadioButtonElement
  • RadioButtonGroupElement
  • MessageInputElement
  • GridElement
  • UploadElement
  • SideNavigationItemElement
  • All text field components (via TextFieldElement and its subclasses)

Usage Example

Implementation Details

Locator Delegation Pattern

Some components override getEnabledLocator() to target a specific internal element rather than the component root. For example, text field components delegate to their input element:
This ensures that the disabled state is checked on the correct element within the component’s shadow DOM.

Playwright’s isEnabled()

The isEnabled() method uses Playwright’s built-in Locator.isEnabled(), which checks whether an element:
  • Does not have the disabled attribute
  • 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