Class SideNavTester

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final T component
    • Constructor Summary

      Constructors 
      Constructor Description
      SideNavTester(T component) Wrap given component for testing.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      void clickItem(String topLevelLabel, Array<String> nestedItemLabels) Simulates a click on the item that matches the given label.
      void expandAndClickItem(String topLevelLabel, Array<String> nestedItemLabels) Simulates a click on the item that matches the given label, expanding potential parent collapsed nodes.
      void click() Simulates a click on the SideNav label, expanding or collapsing item list.
      void toggleItem(String topLevelLabel, Array<String> nestedItemLabels) Simulates a click on the item that matches the given label.
      void toggle() Simulates a click on the SideNav toggle button, expanding or collapsing item list.
      • Methods inherited from class com.vaadin.testbench.unit.ComponentTester

        find, getComponent, isUsable, setModal
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SideNavTester

        SideNavTester(T component)
        Wrap given component for testing.
        Parameters:
        component - target component
    • Method Detail

      • clickItem

         void clickItem(String topLevelLabel, Array<String> nestedItemLabels)

        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 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
      • expandAndClickItem

         void expandAndClickItem(String topLevelLabel, Array<String> nestedItemLabels)

        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 items
      • click

         void click()

        Simulates a click on the SideNav label, expanding or collapsing item list.

      • toggleItem

         void toggleItem(String topLevelLabel, Array<String> nestedItemLabels)

        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 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
      • toggle

         void toggle()

        Simulates a click on the SideNav toggle button, expanding or collapsing item list.