Class SideNavTester<T extends SideNav>
- All Implemented Interfaces:
Clickable<T>
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclick()Simulates a click on the SideNav label, expanding or collapsing item list.voidSimulates a click on the item that matches the given label.voidexpandAndClickItem(String topLevelLabel, String... nestedItemLabels) Simulates a click on the item that matches the given label, expanding potential parent collapsed nodes.voidtoggle()Simulates a click on the SideNav toggle button, expanding or collapsing item list.voidtoggleItem(String topLevelLabel, String... nestedItemLabels) Simulates a click on the item that matches 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, middleClick, middleClick, rightClick, rightClick
-
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. UseexpandAndClickItem(String, String...)to expand intermediate node and click on the desired item.The click is fired as a DOM
clickevent with the left button on the item, so its click listeners run. Then, as in the browser, an item without a path is expanded or collapsed, and an item with a path navigates there unless a click listener prevents the default action. A router-ignored item, or one whose path is an absolute URL, navigates outside the router, recorded as an external navigation. An item with a target other than_self, such as one that opens in a new browser tab, opens its path in that window and leaves the current view as it is.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 items- Throws:
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.The click is fired as a DOM
clickevent with the left button on the item, so its click listeners run. Then, as in the browser, an item without a path is expanded or collapsed, and an item with a path navigates there unless a click listener prevents the default action. A router-ignored item, or one whose path is an absolute URL, navigates outside the router, recorded as an external navigation. An item with a target other than_self, such as one that opens in a new browser tab, opens its path in that window and leaves the current view as it is.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 items- Throws:
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 theSideNavcomponent 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. UseexpandAndClickItem(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 items- Throws:
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 theSideNavcomponent is not collapsible or not usable.- See Also:
-