Class MenuBarLocator

java.lang.Object
com.vaadin.browserless.locator.Locator<MenuBar,MenuBarLocator>
com.vaadin.flow.component.menubar.MenuBarLocator
All Implemented Interfaces:
Clickable<MenuBar>, HasThemeFilter<MenuBar,MenuBarLocator>

@Generated("com.vaadin.browserless.locator.processor.LocatorProcessor") public class MenuBarLocator extends Locator<MenuBar,MenuBarLocator> implements Clickable<MenuBar>, HasThemeFilter<MenuBar,MenuBarLocator>
Generated locator for MenuBar, derived from MenuBarTester. Filter steps are inherited from Locator; action methods delegate to a fresh tester around the resolved component, so behavioral changes belong on the tester, not here.
  • Constructor Details

    • MenuBarLocator

      public MenuBarLocator()
    • MenuBarLocator

      public MenuBarLocator(MenuBar component)
  • Method Details

    • getComponent

      public MenuBar getComponent()
      Description copied from interface: Clickable
      Gets the component being tested.
      Specified by:
      getComponent in interface Clickable<MenuBar>
      Returns:
      the component under test
    • ensureComponentIsUsable

      public void ensureComponentIsUsable()
      Description copied from interface: Clickable
      Ensures the component is in a usable state before interaction.
      Specified by:
      ensureComponentIsUsable in interface Clickable<MenuBar>
    • clickItem

      public void clickItem(String topLevelText, String... nestedItemsText)
      Simulates a click on the item that matches the given text. For nested menu item provide the text of each menu item in the hierarchy. The path to the menu item must reflect what is seen in the browser, meaning that hidden items are ignored.
       
      
       menu.addItem("Preview", event -> {
       });
       var subMenu = menu.addItem("Share").getSubMenu();
       subMenu.addItem("Copy link", event -> {
       });
       subMenu.addItem("Email", event -> {
       });
      
       // clicks top level menu item with text Preview
       wrapper.clickItem("Preview");
      
       // clicks nested menu item with text Email
       wrapper.clickItem("Share", "Email");
       
       
      Javadoc copied from MenuBarTester.clickItem(java.lang.String,java.lang.String[]).
      Parameters:
      topLevelText - the text content of the top level menu item, not null.
      nestedItemsText - text content of the nested menu items
      Throws:
      IllegalArgumentException - if the provided text does not identify a menu item.
      IllegalStateException - if the item at given path is not usable.
    • clickItem

      public void clickItem(int topLevelPosition, int... nestedItemsPositions)
      Simulates a click on the item at the given position in the menu. For nested menu item provide the position of each sub menu that should be navigated to reach the request item. The position reflects what is seen in the browser, so hidden items are ignored.
       
      
       menu.addItem("Preview", event -> {
       });
       var subMenu = menu.addItem("Share").getSubMenu();
       subMenu.addItem("Copy link", event -> {
       });
       subMenu.addItem("Email", event -> {
       });
      
       // clicks top level "Preview" menu item at position 0
       wrapper.clickItem(0);
      
       // clicks then nested menu item at position 1 "Email" through the
       // item "Share" at position 1
       wrapper.clickItem(1, 1);
       
       
      Javadoc copied from MenuBarTester.clickItem(int,int[]).
      Parameters:
      topLevelPosition - the zero-based position of the item in the menu, as it will be seen in the browser.
      nestedItemsPositions - the zero-based position of the nested items, relative to the parent menu
      Throws:
      IllegalArgumentException - if the provided position does not identify a menu item.
      IllegalStateException - if the item at given position is not usable.
    • isItemChecked

      public boolean isItemChecked(String topLevelText, String... nestedItemsText)
      Checks if the checkable menu item matching given text is checked. For nested menu item provide the text of each menu item in the hierarchy. The path to the menu item must reflect what is seen in the browser, meaning that hidden items are ignored.
       
      
       menu.addItem("Preview", event -> {
       }).setCheckable(true);
       var subMenu = menu.addItem("Share").getSubMenu();
       subMenu.addItem("Copy link", event -> {
       }).setCheckable(true);
       subMenu.addItem("Email", event -> {
       }).setCheckable(true);
      
       wrapper.isItemChecked("Preview");
      
       wrapper.isItemChecked("Share", "Email");
       
       
      Javadoc copied from MenuBarTester.isItemChecked(java.lang.String,java.lang.String[]).
      Parameters:
      topLevelText - the text content of the top level menu item, not null.
      nestedItemsText - text content of the nested menu items
      Returns:
      true if the item at given path is checked, otherwise false.
      Throws:
      IllegalArgumentException - if the provided text does not identify a menu item or if the menu item is not checkable.
      IllegalStateException - if the item at given path is not usable.
    • isItemChecked

      public boolean isItemChecked(int topLevelPosition, int... nestedItemsPositions)
      Checks if the checkable menu item at given position is checked. For nested menu item provide the position of each sub menu that should be navigated to reach the requested item. The position reflects what is seen in the browser, so hidden items are ignored.
       
      
       menu.addItem("Preview", event -> {
       }).setCheckable(true);
       var subMenu = menu.addItem("Share").getSubMenu();
       subMenu.addItem("Copy link", event -> {
       }).setCheckable(true);
       subMenu.addItem("Email", event -> {
       }).setCheckable(true);
      
       // checks top level "Preview" menu item at position 0
       wrapper.isItemChecked(0);
      
       // checks nested menu item at position 1 "Email" through the
       // item "Share" at position 1
       wrapper.isItemChecked(1, 1);
       
       
      Javadoc copied from MenuBarTester.isItemChecked(int,int[]).
      Parameters:
      topLevelPosition - the zero-based position of the item in the menu, as it will be seen in the browser.
      nestedItemsPositions - the zero-based position of the nested items, relative to the parent menu
      Throws:
      IllegalArgumentException - if the provided position does not identify a menu item or if the menu item is not checkable.
      IllegalStateException - if the item at given position is not usable.
    • getItemTooltipText

      public String getItemTooltipText(String topLevelText, String... nestedItemsText)
      Gets the tooltip text of the menu item matching the given text. For nested menu item provide the text of each menu item in the hierarchy. The path to the menu item must reflect what is seen in the browser, meaning that hidden items are ignored.
       
      
       menu.addItem("Preview", event -> {
       }).setTooltipText("Preview the document");
       var subMenu = menu.addItem("Share").getSubMenu();
       subMenu.addItem("Email", event -> {
       }).setTooltipText("Send as email");
      
       wrapper.getItemTooltipText("Preview");
      
       wrapper.getItemTooltipText("Share", "Email");
       
       
      Javadoc copied from MenuBarTester.getItemTooltipText(java.lang.String,java.lang.String[]).
      Parameters:
      topLevelText - the text content of the top level menu item, not null.
      nestedItemsText - text content of the nested menu items
      Returns:
      the tooltip text of the menu item at given path, or null if the item has no tooltip set.
      Throws:
      IllegalArgumentException - if the provided text does not identify a menu item.
      IllegalStateException - if the item at given path is not usable.
    • getItemTooltipText

      public String getItemTooltipText(int topLevelPosition, int... nestedItemsPositions)
      Gets the tooltip text of the menu item at the given position in the menu. For nested menu item provide the position of each sub menu that should be navigated to reach the requested item. The position reflects what is seen in the browser, so hidden items are ignored.
       
      
       menu.addItem("Preview", event -> {
       }).setTooltipText("Preview the document");
       var subMenu = menu.addItem("Share").getSubMenu();
       subMenu.addItem("Email", event -> {
       }).setTooltipText("Send as email");
      
       // gets the tooltip of the top level "Preview" item at position 0
       wrapper.getItemTooltipText(0);
      
       // gets the tooltip of the nested "Email" item at position 0 through
       // the item "Share" at position 1
       wrapper.getItemTooltipText(1, 0);
       
       
      Javadoc copied from MenuBarTester.getItemTooltipText(int,int[]).
      Parameters:
      topLevelPosition - the zero-based position of the item in the menu, as it will be seen in the browser.
      nestedItemsPositions - the zero-based position of the nested items, relative to the parent menu
      Returns:
      the tooltip text of the menu item at given position, or null if the item has no tooltip set.
      Throws:
      IllegalArgumentException - if the provided position does not identify a menu item.
      IllegalStateException - if the item at given position is not usable.