Skip to main content

ComboBoxElement

Playwright element wrapper for <vaadin-combo-box>. Provides helpers to open the overlay, filter items, and pick items by visible text, along with aria/placeholder/validation mixins.

Component Tag

vaadin-combo-box

Implements

  • FocusableElement
  • HasAriaLabelElement
  • HasInputFieldElement
  • HasPrefixElement
  • HasThemeElement
  • HasPlaceholderElement
  • HasEnabledElement
  • HasTooltipElement
  • HasValidationPropertiesElement
  • HasClearButtonElement
  • HasAllowedCharPatternElement

Factory Methods

getByLabel (Page)

Get the ComboBoxElement by its label. Uses ARIA role COMBOBOX.
Page
required
The Playwright page
String
required
The accessible label of the field
Returns: The matching ComboBoxElement

getByLabel (Locator)

Get the ComboBoxElement by its label within a given scope.
Locator
required
The locator to search within
String
required
The accessible label of the field
Returns: The matching ComboBoxElement

Constructor

ComboBoxElement

Create a new ComboBoxElement.
Locator
required
The locator for the <vaadin-combo-box> element

Methods

selectItem

Select an item by its visible label. Opens the overlay and clicks the matching item.
String
required
Label of the item to select

filterAndSelectItem

Type filter text into the input, then click the matching item.
String
required
Text to type for filtering
String
required
Label of the item to select

setFilter

Type into the input to trigger filtering. Uses pressSequentially to fire keyboard events that the ComboBox listens to for filtering.
String
required
The filter text

getFilter

Get the current filter value from the DOM property. Returns: The current filter string

open

Open the combo box overlay.

close

Close the combo box overlay.

isOpened

Check whether the overlay is currently open. Returns: true when the overlay is open

assertOpened

Assert that the combo box overlay is open.

assertClosed

Assert that the combo box overlay is closed.

getValue

Get the selected value label. ComboBox stores an index in its value property, so this reads the displayed text from the input element instead. Returns: The displayed value or empty string when nothing is selected

assertValue

Assert that the displayed value equals the expected string.
String
Expected label or empty string for no selection

isReadOnly

Check whether the combo box is read-only. Returns: true when read-only

assertReadOnly

Assert that the combo box is read-only.

assertNotReadOnly

Assert that the combo box is not read-only.

getToggleButtonLocator

Get locator for the toggle button part. Returns: Locator for the toggle button

clickToggleButton

Click the dropdown toggle button.

getOverlayItemCount

Count visible overlay items. Returns: The number of visible items

assertItemCount

Assert that the overlay contains exactly the expected number of items.
int
required
Expected item count

getFocusLocator

Get the locator to use for focus operations. Returns: The input locator

getAriaLabelLocator

Get the locator for ARIA label. Returns: The input locator

getEnabledLocator

Get the locator to use for enabled/disabled checks. Returns: The input locator

Usage Examples

Basic Selection

Filter and Select

Open/Close Overlay

Item Count

Clear Selection

Read-Only State

Validation

Lazy Loading with Filter

Custom Value Entry