Class TabSheetTester<T extends com.vaadin.flow.component.tabs.TabSheet>
- Type Parameters:
T- component type
- All Implemented Interfaces:
Clickable<T>
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets 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.<E extends com.vaadin.flow.component.Component>
EgetTabContent(int index) Gets the content of the visible tab at given index.<E extends com.vaadin.flow.component.Component>
EgetTabContent(String label) Gets the content of 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.ComponentTester
blur, canSetValueAsUser, clearAsUser, clickClearButtonAsUser, ensureComponentIsUsable, ensureComponentIsUsable, ensureComponentIsUsableOrDetach, ensureVisible, ensureVisible, find, findAllByQuery, findByQuery, fireDomEvent, fireDomEvent, fireDomEvent, focus, getComponent, getField, getField, getMethod, getMethod, isComponentReadOnly, isFocused, isUsable, isUsable, notUsableReasons, notUsableReasons, roundTrip, setModal, setPropertyAsUser, setValueAsUser, setValueAsUserMethods 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, rightClick
-
Constructor Details
-
TabSheetTester
Wrap given component for testing.- Parameters:
component- target component
-
-
Method Details
-
select
Selects the tab with the given label.- Parameters:
label- the tab label- Throws:
IllegalArgumentException- if the tab with givenlabelis not visible.IllegalStateException- if tab is not usable in the browser
-
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).- Parameters:
index- the zero-based index of the selected tab, negative value to unselect- Throws:
IllegalStateException- if tab at give index is not usable in the browser
-
isSelected
Checks if the tab with the given label is currently selected.- Parameters:
label- the tab label- Returns:
- true if the tab is selected, false otherwise.
- Throws:
IllegalArgumentException- if the tab with givenlabelis not visible.
-
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).- 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 browser
-
getTab
Gets the visible tab with the given label.- 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).- Parameters:
index- the zero-based index of the selected tab, negative value to unselect- Returns:
- the tab at the 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.
-
getTabContent
Gets the content of the visible tab with the given label.- Type Parameters:
E- the event type- Parameters:
label- the tab label- Returns:
- the content of the tab with the given label
- Throws:
IllegalStateException- if tab is not visible
-
getTabContent
public <E extends com.vaadin.flow.component.Component> E getTabContent(int index) Gets the content of 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 the content of tab 'C', the call must begetTabContent(1)and notgetTabContent(2).- Type Parameters:
E- the event type- Parameters:
index- the zero-based index of the selected tab, negative value to unselect- Returns:
- the content of the tab at the given index
- Throws:
IllegalStateException- if tab is not visibleIllegalArgumentException- 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
select(int)andgetTab(int)accept.Each entry is the tab's
label, the same text thatselect(String)andgetTab(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.
- 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
isSelected(String)reports it.- Returns:
- the label of the selected tab, or
nullif no tab is selected - Throws:
IllegalStateException- if the component is not visible
-