Class MultiSelectComboBoxLocator<Y>
- Type Parameters:
Y- the MultiSelectComboBox's Y type parameter
- All Implemented Interfaces:
Clickable<MultiSelectComboBox<Y>>,HasAriaLabelFilter<MultiSelectComboBox<Y>,,MultiSelectComboBoxLocator<Y>> HasLabelFilter<MultiSelectComboBox<Y>,,MultiSelectComboBoxLocator<Y>> HasPlaceholderFilter<MultiSelectComboBox<Y>,,MultiSelectComboBoxLocator<Y>> HasThemeFilter<MultiSelectComboBox<Y>,,MultiSelectComboBoxLocator<Y>> HasValueFilter<MultiSelectComboBox<Y>,Set<Y>, MultiSelectComboBoxLocator<Y>>
MultiSelectComboBox, derived from
MultiSelectComboBoxTester. Filter steps are inherited from
Locator; action methods delegate to a fresh tester
around the resolved component, so behavioral changes belong on the
tester, not here.-
Constructor Summary
ConstructorsConstructorDescriptionMultiSelectComboBoxLocator(MultiSelectComboBox<Y> component) Creates a locator already bound to the given component, so that the action methods run against it instead of against a lookup.MultiSelectComboBoxLocator(Class<Y> yType) Creates a locator that searches for aMultiSelectComboBox. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the selection by clicking the clear button, as the user would.voidEnsures the component is in a usable state before interaction.Gets the component being tested.Get the currently selected item.Get the actual items for the dropdown as a List.Get dropdown suggestions as String representations sent to the client.voidselectItem(String... selection) Select items by client string representation.voidselectItemContaining(String text) Selects the item matching a partial text, as if the user typed the text into the combobox and picked the only remaining suggestion.voidselectItemsContaining(String... texts) Selects every item matching partial texts, as if the user typed each text into the combobox and ticked all remaining suggestions.voidSimulate writing a filter to the combobox.Methods inherited from class com.vaadin.browserless.locator.Locator
atIndex, component, components, exists, inside, inside, invalidate, self, with, withAttribute, withAttribute, withClassName, withCondition, withCondition, withId, withinSlot, withoutAttribute, withoutAttribute, withoutClassName, withTestIdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.browserless.Clickable
click, click, click, middleClick, middleClick, rightClick, rightClickMethods inherited from interface com.vaadin.browserless.locator.HasAriaLabelFilter
withAriaLabel, withAriaLabelContainingMethods inherited from interface com.vaadin.browserless.locator.HasLabelFilter
withLabel, withLabelContainingMethods inherited from interface com.vaadin.browserless.locator.HasPlaceholderFilter
withPlaceholder, withPlaceholderContainingMethods inherited from interface com.vaadin.browserless.locator.HasThemeFilter
withoutTheme, withoutTheme, withTheme, withThemeMethods inherited from interface com.vaadin.browserless.locator.HasValueFilter
withValue
-
Constructor Details
-
MultiSelectComboBoxLocator
Creates a locator that searches for aMultiSelectComboBox.- Parameters:
yType- class witness pinning the Y type parameter; the value is unused
-
MultiSelectComboBoxLocator
Creates a locator already bound to the given component, so that the action methods run against it instead of against a lookup.- Parameters:
component- the component the locator resolves to
-
-
Method Details
-
getComponent
Description copied from interface:ClickableGets the component being tested.- Specified by:
getComponentin interfaceClickable<Y>- Returns:
- the component under test
-
ensureComponentIsUsable
public void ensureComponentIsUsable()Description copied from interface:ClickableEnsures the component is in a usable state before interaction.- Specified by:
ensureComponentIsUsablein interfaceClickable<Y>
-
setFilter
Simulate writing a filter to the combobox. As typing does in the browser, the filter is applied to the data provider and to the component'sfilterproperty.Use
MultiSelectComboBoxTester.getSuggestions()to get the string values show in the dropdown orMultiSelectComboBoxTester.getSuggestionItems()to get the actual items in the suggestion. Javadoc copied fromMultiSelectComboBoxTester.setFilter(java.lang.String).- Parameters:
filter- string to use for filtering
-
selectItem
Select items by client string representation. Javadoc copied fromMultiSelectComboBoxTester.selectItem(java.lang.String[]).- Parameters:
selection- item representations as strings- Throws:
IllegalStateException- if the component is not usable
-
selectItemContaining
Selects the item matching a partial text, as if the user typed the text into the combobox and picked the only remaining suggestion.The text is applied as a filter, so matching follows the component's own filtering: by default a case-insensitive "label contains" match, or the
ItemFilter/ data provider filter the application configured. Exactly one item has to match, so a test fails rather than picking an item it did not clearly name. This also applies when the text equals the full label of one of the matching items; useselectItemto pick an item by its exact label. This rule does not depend on the component'sPartialMatchMode. UseMultiSelectComboBoxTester.selectItemsContaining(String...)to pick every item a text matches.As in the browser, the item is added to the current selection. Unlike the browser, where picking an already selected item deselects it, an already selected item stays selected. Afterwards the filter is cleared, or kept at the text when
keepFilteris enabled, as in the browser. It also stays when a value change listener disables, hides or detaches the component, or makes it inert, as the server then ignores the browser's update. If matching fails, the selection is left unchanged and the filter set before the call is restored.// items "Berlin", "Bern", "Bernau", "Helsinki" comboBoxTester.selectItemContaining("hel"); // adds "Helsinki" comboBoxTester.selectItemContaining("bernau"); // adds "Bernau" comboBoxTester.selectItemContaining("bern"); // throws, "Bern" and // "Bernau" matchJavadoc copied fromMultiSelectComboBoxTester.selectItemContaining(java.lang.String).- Parameters:
text- the text the user types to find the item, notnull- Throws:
IllegalArgumentException- if the text isnull, matches no item, or matches more than one itemIllegalStateException- if the component is not usable- See Also:
-
selectItemsContaining
Selects every item matching partial texts, as if the user typed each text into the combobox and ticked all remaining suggestions.Each text is applied as a filter, so matching follows the component's own filtering: by default a case-insensitive "label contains" match, or the
ItemFilter/ data provider filter the application configured. Every text has to match at least one item. UseMultiSelectComboBoxTester.selectItemContaining(java.lang.String)to pick exactly one item.As in the browser, the matched items are added to the current selection. Unlike the browser, where picking an already selected item deselects it, already selected matches stay selected, so an item matched by more than one text is selected once. All matches are committed in one value change. In the browser, ticking several matches of one text needs
keepFilter, because the filter is otherwise cleared after each pick, and every pick is its own value change. Afterwards the filter is cleared, or kept at the last text whenkeepFilteris enabled, as in the browser. It also stays when a value change listener disables, hides or detaches the component, or makes it inert, as the server then ignores the browser's update. If matching fails, the selection is left unchanged and the filter set before the call is restored.// items "Berlin", "Bern", "Helsinki" comboBoxTester.selectItemsContaining("ber"); // adds Berlin, Bern comboBoxTester.selectItemsContaining("hel", "lin"); // adds Helsinki, // BerlinJavadoc copied fromMultiSelectComboBoxTester.selectItemsContaining(java.lang.String[]).- Parameters:
texts- the texts the user types to find the items, at least one, none of themnull- Throws:
IllegalArgumentException- if no text is given, a text isnull, or a text matches no itemIllegalStateException- if the component is not usable- See Also:
-
clickClearButton
public void clickClearButton()Clears the selection by clicking the clear button, as the user would.Requires the clear button to be visible — a hidden clear button is not something the user can click.
MultiSelectComboBoxTester.selectItem(String...)withnullclears the selection without that requirement. Javadoc copied fromMultiSelectComboBoxTester.clickClearButton().- Throws:
IllegalStateException- if the component is not usable, or its clear button is not visible- Since:
- 25.3
-
getSelected
Get the currently selected item. Javadoc copied fromMultiSelectComboBoxTester.getSelected().- Returns:
- current selection
-
getSuggestions
Get dropdown suggestions as String representations sent to the client. Any filter that is set is taken into account. Javadoc copied fromMultiSelectComboBoxTester.getSuggestions().- Returns:
- List of item representation strings
-
getSuggestionItems
Get the actual items for the dropdown as a List. Any filter that is set is taken into account. Javadoc copied fromMultiSelectComboBoxTester.getSuggestionItems().- Returns:
- List of items
-