com.vaadin.flow.component.sidenav.
Class SideNavTester<T extends SideNav>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
click()
Simulates a click on the SideNav label, expanding or collapsing item list.
void
Simulates a click on the item that matches the given label.
void
expandAndClickItem
(String topLevelLabel, String... nestedItemLabels) Simulates a click on the item that matches the given label, expanding potential parent collapsed nodes.
void
toggle()
Simulates a click on the SideNav toggle button, expanding or collapsing item list.
void
toggleItem
(String topLevelLabel, String... nestedItemLabels) Simulates a click on the item that matches the given label.
Methods inherited from class com.vaadin.testbench.unit.ComponentTester
ensureComponentIsUsable, ensureComponentIsUsable, ensureVisible, ensureVisible, find, findAllByQuery, findByQuery, fireDomEvent, fireDomEvent, fireDomEvent, getComponent, getField, getField, getMethod, getMethod, isUsable, isUsable, notUsableReasons, notUsableReasons, roundTrip, setModal
-
Constructor Details
-
SideNavTester
Wrap given component for testing.
Parameters:
component
- target component
-
-
Method Details
-
clickItem
Simulates a click on the item that matches the given label. For nested navigation item provide the label of each item in the hierarchy. The path to the navigation item must reflect what is seen in the browser, meaning that hidden items are ignored. For the same reason, items inside collapsed nodes cannot be clicked and an exception is thrown. Use
expandAndClickItem(String, String...)
to expand intermediate node and click on the desired item.sideNav.addItem(new SideNavItem("Home", HomeView.class)); SideNavItem childNav = new SideNavItem("Messages"); childNav.addItem(new SideNavItem("Inbox", InboxView.class)); childNav.addItem(new SideNavItem("Sent", SentView.class)); sideNav.addItem(childNav); // clicks top level navigation item with label Home tester.clickItem("Home"); // clicks nested navigation item with label Sent wrapper.clickItem("Messages", "Sent");
Parameters:
topLevelLabel
- the text content of the top level SideNav item label, not null.nestedItemLabels
- labels of the nested SideNav itemsThrows:
IllegalArgumentException
- if the provided text does not identify a SideNav item.IllegalStateException
- if the item at given path is not usable.See Also:
-
expandAndClickItem
Simulates a click on the item that matches the given label, expanding potential parent collapsed nodes. For nested navigation item provide the label of each item in the hierarchy. The path to the navigation item must reflect what is seen in the browser, meaning that hidden items are ignored. For the same reason, items inside collapsed nodes cannot be clicked and an exception is thrown.
sideNav.addItem(new SideNavItem("Home", HomeView.class)); SideNavItem childNav = new SideNavItem("Messages"); childNav.addItem(new SideNavItem("Inbox", InboxView.class)); childNav.addItem(new SideNavItem("Sent", SentView.class)); sideNav.addItem(childNav); // clicks nested navigation item with label Sent wrapper.expandAndClickItem("Messages", "Sent");
Parameters:
topLevelLabel
- the text content of the top level SideNav item label, not null.nestedItemLabels
- labels of the nested SideNav itemsThrows:
IllegalArgumentException
- if the provided text does not identify a SideNav item.IllegalStateException
- if the item at given path is not usable.See Also:
-
click
public void click()Simulates a click on the SideNav label, expanding or collapsing item list.
Throws:
IllegalStateException
- if theSideNav
component is not collapsible or not usable.See Also:
-
toggleItem
Simulates a click on the item that matches the given label. For nested navigation item provide the label of each item in the hierarchy. The path to the navigation item must reflect what is seen in the browser, meaning that hidden items are ignored. For the same reason, items inside collapsed nodes cannot be clicked and an exception is thrown. Use
expandAndClickItem(String, String...)
to expand intermediate node and click on the desired item.sideNav.addItem(new SideNavItem("Home", HomeView.class)); SideNavItem childNav = new SideNavItem("Messages"); childNav.addItem(new SideNavItem("Inbox", InboxView.class)); childNav.addItem(new SideNavItem("Sent", SentView.class)); sideNav.addItem(childNav); // clicks top level navigation item with label Home tester.clickItem("Home"); // clicks nested navigation item with label Sent wrapper.clickItem("Messages", "Sent");
Parameters:
topLevelLabel
- the text content of the top level SideNav item label, not null.nestedItemLabels
- labels of the nested SideNav itemsThrows:
IllegalArgumentException
- if the provided text does not identify a SideNav item.IllegalStateException
- if the item at given path is not usable.See Also:
-
toggle
public void toggle()Simulates a click on the SideNav toggle button, expanding or collapsing item list.
Throws:
IllegalStateException
- if theSideNav
component is not collapsible or not usable.See Also:
-