MultiSelectComboBoxElement
Playwright element wrapper for <vaadin-multi-select-combo-box>. Provides helpers to open the overlay, filter items, select/deselect multiple items, and query selected chips.
Component Tag
vaadin-multi-select-combo-box
Implements
FocusableElement
HasAriaLabelElement
HasInputFieldElement
HasThemeElement
HasPlaceholderElement
HasEnabledElement
HasTooltipElement
HasValidationPropertiesElement
HasClearButtonElement
HasAllowedCharPatternElement
Factory Methods
getByLabel (Page)
public static MultiSelectComboBoxElement getByLabel(Page page, String label)
Get the MultiSelectComboBoxElement by its label. Uses ARIA role COMBOBOX.
The accessible label of the field
Returns: The matching MultiSelectComboBoxElement
getByLabel (Locator)
public static MultiSelectComboBoxElement getByLabel(Locator locator, String label)
Get the MultiSelectComboBoxElement by its label within a given scope.
The locator to search within
The accessible label of the field
Returns: The matching MultiSelectComboBoxElement
Constructor
MultiSelectComboBoxElement
public MultiSelectComboBoxElement(Locator locator)
Create a new MultiSelectComboBoxElement.
The locator for the <vaadin-multi-select-combo-box> element
Selection Methods
selectItem
public void selectItem(String item)
Select an item by its visible label. Opens the overlay and clicks the matching item (toggling its selection).
Label of the item to select
deselectItem
public void deselectItem(String item)
Deselect an item by its visible label. Opens the overlay and clicks the matching item (toggling its selection off).
Label of the item to deselect
selectItems
public void selectItems(String... items)
Select multiple items in sequence.
Labels of the items to select
deselectItems
public void deselectItems(String... items)
Deselect multiple items in sequence.
Labels of the items to deselect
filterAndSelectItem
public void filterAndSelectItem(String filter, String item)
Type filter text into the input, then click the matching item.
Text to type for filtering
Label of the item to select
Filter Methods
setFilter
public void setFilter(String filter)
Type into the input to trigger filtering. Uses pressSequentially to fire keyboard events that the component listens to for filtering.
getFilter
public String getFilter()
Get the current filter value from the DOM property.
Returns: The current filter string
Open/Close Methods
open
Open the combo box overlay.
close
Close the combo box overlay.
isOpened
public boolean isOpened()
Check whether the overlay is currently open.
Returns: true when the overlay is open
assertOpened
public void assertOpened()
Assert that the combo box overlay is open.
assertClosed
public void assertClosed()
Assert that the combo box overlay is closed.
Value Methods
getValue
@Override
public String getValue()
Get the selected values as a comma-separated string from the selectedItems property.
Returns: Comma-separated selected values, or empty string when nothing is selected
assertValue
@Override
public void assertValue(String expected)
Assert that the displayed value equals the expected string.
Expected comma-separated value or empty string for no selection
Read-Only Methods
isReadOnly
public boolean isReadOnly()
Check whether the combo box is read-only.
Returns: true when read-only
assertReadOnly
public void assertReadOnly()
Assert that the combo box is read-only.
assertNotReadOnly
public void assertNotReadOnly()
Assert that the combo box is not read-only.
public Locator getToggleButtonLocator()
Get locator for the toggle button part.
Returns: Locator for the toggle button
public void clickToggleButton()
Click the dropdown toggle button.
Overlay Item Methods
getOverlayItemCount
public int getOverlayItemCount()
Count visible overlay items.
Returns: The number of visible items
assertItemCount
public void assertItemCount(int expected)
Assert that the overlay contains exactly the expected number of items.
Chip Methods
getChipLocators
public Locator getChipLocators()
Get the locator for all non-overflow chips.
Returns: Locator for selected-value chips
getOverflowChipLocator
public Locator getOverflowChipLocator()
Get the locator for the overflow chip.
Returns: Locator for the overflow chip
getSelectedItems
public List<String> getSelectedItems()
Get the labels of all currently selected items by reading the selectedItems property from the web component.
Returns: List of selected item labels
getSelectedItemCount
public int getSelectedItemCount()
Get the count of currently selected items from the selectedItems property.
Returns: Number of selected items
assertSelectedItems
public void assertSelectedItems(String... expected)
Assert that the selected item labels match the expected values.
assertSelectedCount
public void assertSelectedCount(int expected)
Assert that the number of selected items matches.
Expected number of selected items
Component Query Methods
getOverlayItemComponent (by text)
public <T extends VaadinElement> T getOverlayItemComponent(String itemText, Class<T> type)
Get a typed component element from an overlay item matching the given text. The component class must be annotated with @PlaywrightElement and have a public constructor accepting a single Locator parameter.
Text of the overlay item to search in
The element class (e.g., ButtonElement.class)
Returns: The first matching component inside the item
getOverlayItemComponent (by index)
public <T extends VaadinElement> T getOverlayItemComponent(int index, Class<T> type)
Get a typed component element from an overlay item at the given visible index. The component class must be annotated with @PlaywrightElement and have a public constructor accepting a single Locator parameter.
0-based visible item index
The element class (e.g., ButtonElement.class)
Returns: The first matching component inside the item
Locator Methods
getFocusLocator
@Override
public Locator getFocusLocator()
Get the locator to use for focus operations.
Returns: The input locator
getAriaLabelLocator
@Override
public Locator getAriaLabelLocator()
Get the locator for ARIA label.
Returns: The input locator
getEnabledLocator
@Override
public Locator getEnabledLocator()
Get the locator to use for enabled/disabled checks.
Returns: The input locator
Usage Examples
Basic Multi-Selection
MultiSelectComboBoxElement comboBox = MultiSelectComboBoxElement.getByLabel(page, "Fruits");
comboBox.assertVisible();
comboBox.selectItems("Apple", "Cherry");
comboBox.close();
comboBox.assertSelectedCount(2);
Deselection
MultiSelectComboBoxElement comboBox = MultiSelectComboBoxElement.getByLabel(page, "Fruits");
comboBox.selectItems("Apple", "Cherry");
comboBox.close();
comboBox.assertSelectedCount(2);
comboBox.deselectItem("Apple");
comboBox.close();
comboBox.assertSelectedCount(1);
Filter and Select
MultiSelectComboBoxElement comboBox = MultiSelectComboBoxElement.getByLabel(page, "Filterable MultiSelect");
comboBox.filterAndSelectItem("Apr", "Apricot");
comboBox.close();
comboBox.assertSelectedCount(1);
Clear Selection
MultiSelectComboBoxElement comboBox = MultiSelectComboBoxElement.getByLabel(page, "MultiSelect with placeholder and clear button");
comboBox.selectItems("Apple", "Banana");
comboBox.close();
comboBox.assertSelectedCount(2);
comboBox.clickClearButton();
comboBox.assertSelectedCount(0);
Verify Selected Items
MultiSelectComboBoxElement comboBox = MultiSelectComboBoxElement.getByLabel(page, "Fruits");
comboBox.selectItems("Apple", "Cherry");
comboBox.close();
assertTrue(comboBox.getSelectedItems().contains("Apple"));
assertTrue(comboBox.getSelectedItems().contains("Cherry"));
comboBox.assertSelectedCount(2);
Lazy Loading
MultiSelectComboBoxElement comboBox = MultiSelectComboBoxElement.getByLabel(page, "Lazy MultiSelect");
comboBox.filterAndSelectItem("Item 250", "Item 250");
comboBox.close();
comboBox.assertSelectedCount(1);
assertThat(page.locator("#lazy-selected-value")).hasText("Item 250");
Custom Renderer with Components
MultiSelectComboBoxElement comboBox = MultiSelectComboBoxElement.getByLabel(page, "Custom renderer");
comboBox.open();
ButtonElement button = comboBox.getOverlayItemComponent("Apple", ButtonElement.class);
button.assertVisible();
assertThat(button.getLocator()).hasText("Info Apple");
// Click the button inside an item
ButtonElement bananaButton = comboBox.getOverlayItemComponent("Banana", ButtonElement.class);
bananaButton.click();
assertThat(page.locator("#custom-renderer-output")).hasText("Clicked: Banana");
Read-Only State
MultiSelectComboBoxElement comboBox = MultiSelectComboBoxElement.getByLabel(page, "Read-only MultiSelect");
comboBox.assertVisible();
comboBox.assertReadOnly();
comboBox.assertSelectedCount(2);
Validation
MultiSelectComboBoxElement comboBox = MultiSelectComboBoxElement.getByLabel(page, "MultiSelect with theme");
comboBox.assertValid();
ButtonElement.getByText(page, "Validate").click();
comboBox.assertInvalid();
assertThat(comboBox.getErrorMessageLocator()).hasText("Required field");