Class ComboBoxTester
-
- All Implemented Interfaces:
-
com.vaadin.browserless.Clickable
public class ComboBoxTester<T extends ComboBox<Y>, Y> extends ComponentTester<T>
- Since:
1.0
-
-
Constructor Summary
Constructors Constructor Description ComboBoxTester(T component)Wrap given component for testing.
-
Method Summary
Modifier and Type Method Description voidsetFilter(String filter)Simulate writing a filter to the combobox. voidselectItem(String selection)Selects an item by its string representation (label). YgetSelected()Get the currently selected item. List<String>getSuggestions()Get dropdown suggestions as String representations sent to the client. List<Y>getSuggestionItems()Get the actual items for the dropdown as a List. -
Methods inherited from class com.vaadin.browserless.ComponentTester
ensureComponentIsUsable, find, getComponent, isUsable, setModal -
Methods inherited from class com.vaadin.browserless.Clickable
click, click, click, middleClick, middleClick, rightClick, rightClick -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ComboBoxTester
ComboBoxTester(T component)
Wrap given component for testing.
- Parameters:
component- target component
-
-
Method Detail
-
setFilter
void setFilter(String filter)
Simulate writing a filter to the combobox.
Use getSuggestions to get the string values show in the dropdown or getSuggestionItems to get the actual items in the suggestion.- Parameters:
filter- string to use for filtering
-
selectItem
void selectItem(String selection)
Selects an item by its string representation (label).
This method searches for the item among the current suggestions, which are affected by any filter set via setFilter. If no filter is set, all items are available for selection. If a filter is set, only the filtered items can be selected.
To select an item when the ComboBox uses custom filtering logic (e.g., set via
setItems(ItemFilter, Collection)), first call setFilter to apply the filter, then call this method to select from the filtered results.Example usage with filtering:
// Apply filter first comboBoxTester.setFilter("search text"); // Then select from filtered items comboBoxTester.selectItem("Matching Item Label");- Parameters:
selection- the item's string representation (label) to select, ornullto clear the selection
-
getSelected
Y getSelected()
Get the currently selected item.
- Returns:
current selection
-
getSuggestions
List<String> getSuggestions()
Get dropdown suggestions as String representations sent to the client. Any filter that is set is taken into account.
- Returns:
List of item representation strings
-
getSuggestionItems
List<Y> getSuggestionItems()
Get the actual items for the dropdown as a List. Any filter that is set is taken into account.
- Returns:
List of items
-
-
-
-