Class TabsTester<T extends com.vaadin.flow.component.tabs.Tabs>

java.lang.Object
com.vaadin.browserless.ComponentTester<T>
com.vaadin.flow.component.tabs.TabsTester<T>
Type Parameters:
T - component type
All Implemented Interfaces:
Clickable<T>

public class TabsTester<T extends com.vaadin.flow.component.tabs.Tabs> extends ComponentTester<T>
Tester for Tabs components.
Since:
1.0
  • Constructor Details

    • TabsTester

      public TabsTester(T component)
      Wrap given component for testing.
      Parameters:
      component - target component
  • Method Details

    • select

      public void select(String label)
      Selects the tab with the given label.
      Parameters:
      label - the tab label
    • select

      public void select(int index)
      Selects a visible tab based on its zero-based index.

      The index refers 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 be select(1) and not select(2).

      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 browser
      IllegalArgumentException - if the index is less than zero or greater than the number of visible tabs.
    • isSelected

      public boolean isSelected(String label)
      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.
    • isSelected

      public boolean isSelected(int index)
      Checks if the visible tab at the given index is currently selected.

      The index refers 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 be isSelected(1) and not isSelected(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
      IllegalArgumentException - if the index is less than zero or greater than the number of visible tabs.
    • getTab

      public com.vaadin.flow.component.tabs.Tab getTab(String label)
      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 index refers 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 be getTab(1) and not getTab(2).

      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 browser
      IllegalArgumentException - if the index is less than zero or greater than the number of visible tabs.
    • getTabLabels

      public List<String> 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) and getTab(int) accept.

      Each entry is the tab's label, the same text that select(String) and getTab(String) match. A tab whose caption is made of components, such as an icon and a Span, 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

      public String 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 null if no tab is selected
      Throws:
      IllegalStateException - if the component is not visible