Class TabsLocator
- All Implemented Interfaces:
Clickable<com.vaadin.flow.component.tabs.Tabs>,HasThemeFilter<com.vaadin.flow.component.tabs.Tabs,TabsLocator>
Tabs, derived from
TabsTester. 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
ConstructorsConstructorDescriptionCreates a locator that searches for aTabs.TabsLocator(com.vaadin.flow.component.tabs.Tabs component) Creates a locator already bound to the given component, so that the action methods run against it instead of against a lookup. -
Method Summary
Modifier and TypeMethodDescriptionvoidEnsures the component is in a usable state before interaction.com.vaadin.flow.component.tabs.TabsGets the component being tested.Gets the label of the selected tab.com.vaadin.flow.component.tabs.TabgetTab(int index) Gets the visible tab at given index.com.vaadin.flow.component.tabs.TabGets the visible tab with the given label.Gets the labels of the visible tabs, in the order the user sees them.booleanisSelected(int index) Checks if the visible tab at the given index is currently selected.booleanisSelected(String label) Checks if the tab with the given label is currently selected.voidselect(int index) Selects a visible tab based on its zero-based index.voidSelects the tab with the given label.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.HasThemeFilter
withoutTheme, withoutTheme, withTheme, withTheme
-
Constructor Details
-
TabsLocator
public TabsLocator()Creates a locator that searches for aTabs. -
TabsLocator
public TabsLocator(com.vaadin.flow.component.tabs.Tabs component) 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
public com.vaadin.flow.component.tabs.Tabs getComponent()Description copied from interface:ClickableGets the component being tested.- Specified by:
getComponentin interfaceClickable<com.vaadin.flow.component.tabs.Tabs>- 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<com.vaadin.flow.component.tabs.Tabs>
-
select
Selects the tab with the given label. Javadoc copied fromTabsTester.select(java.lang.String).- Parameters:
label- the tab label
-
select
public void select(int index) Selects a visible tab based on its zero-based index.The
indexrefers to the zero-base position of the currently visible tabs. For example, if there are three tabs A (position 0), B (position 1) and C (position 2), but tab 'B' is hidden, then to select tab 'C', the call must beselect(1)and notselect(2). Javadoc copied fromTabsTester.select(int).- Parameters:
index- the zero-based index of the selected tab, negative value to unselect- Throws:
IllegalStateException- if tab at given index is not visible in the browserIllegalArgumentException- if theindexis less than zero or greater than the number of visible tabs.
-
isSelected
Checks if the tab with the given label is currently selected. Javadoc copied fromTabsTester.isSelected(java.lang.String).- Parameters:
label- the tab label- Returns:
- true if the tab is selected, false otherwise.
-
isSelected
public boolean isSelected(int index) Checks if the visible tab at the given index is currently selected.The
indexrefers to the zero-base position of the currently visible tabs. For example, if there are three tabs A (position 0), B (position 1) and C (position 2), but tab 'B' is hidden, then to check if tab 'C' is selected, the call must beisSelected(1)and notisSelected(2). Javadoc copied fromTabsTester.isSelected(int).- Parameters:
index- the zero-based index of the tab- Returns:
- true if the tab is selected, false otherwise.
- Throws:
IllegalStateException- if tab at given index is not visible in the browserIllegalArgumentException- if theindexis less than zero or greater than the number of visible tabs.
-
getTab
Gets the visible tab with the given label. Javadoc copied fromTabsTester.getTab(java.lang.String).- Parameters:
label- the tab label- Returns:
- the visible tab with the given label
- Throws:
IllegalStateException- if tab is not visible
-
getTab
public com.vaadin.flow.component.tabs.Tab getTab(int index) Gets the visible tab at given index.The
indexrefers to the zero-base position of the currently visible tabs. For example, if there are three tabs A (position 0), B (position 1) and C (position 2), but tab 'B' is hidden, then to get tab 'C', the call must begetTab(1)and notgetTab(2). Javadoc copied fromTabsTester.getTab(int).- Parameters:
index- the zero-based index of the selected tab, negative value to unselect- Returns:
- the visible tab at given index
- Throws:
IllegalStateException- if tab at given index is not visible in the browserIllegalArgumentException- if theindexis less than zero or greater than the number of visible tabs.
-
getTabLabels
Gets the labels of the visible tabs, in the order the user sees them.Hidden tabs are left out, so the position of a label in the returned list is the index that
TabsTester.select(int)andTabsTester.getTab(int)accept.Each entry is the tab's
label, the same text thatTabsTester.select(java.lang.String)andTabsTester.getTab(java.lang.String)match. A tab whose caption is made of components, such as an icon and aSpan, has no label of its own and is listed as an empty string.This only reads the tabs, so it also works when the component is disabled. Javadoc copied from
TabsTester.getTabLabels().- Returns:
- the labels of the visible tabs, never
null - Throws:
IllegalStateException- if the component is not visible
-
getSelectedTabLabel
Gets the label of the selected tab.This only reads the selection, so it also works when the component is disabled. A selected tab that is hidden is still reported, the same way
TabsTester.isSelected(java.lang.String)reports it. Javadoc copied fromTabsTester.getSelectedTabLabel().- Returns:
- the label of the selected tab, or
nullif no tab is selected - Throws:
IllegalStateException- if the component is not visible
-