Class GridContextMenuLocator<Y>
java.lang.Object
com.vaadin.browserless.locator.Locator<GridContextMenu<Y>,GridContextMenuLocator<Y>>
com.vaadin.flow.component.grid.contextmenu.GridContextMenuLocator<Y>
- All Implemented Interfaces:
Clickable<GridContextMenu<Y>>
@Generated("com.vaadin.browserless.locator.processor.LocatorProcessor")
public class GridContextMenuLocator<Y>
extends Locator<GridContextMenu<Y>,GridContextMenuLocator<Y>>
implements Clickable<GridContextMenu<Y>>
Generated locator for
GridContextMenu, derived from
GridContextMenuTester. 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 Summary
ConstructorsConstructorDescriptionGridContextMenuLocator(GridContextMenu<Y> component) GridContextMenuLocator(Class<Y> yType) -
Method Summary
Modifier and TypeMethodDescriptionvoidclickItem(int topLevelPosition, int... nestedItemsPositions) Simulates a click on the item at the given position in the menu.voidSimulates a click on the item that matches the given text.voidclose()Closes the context menu.voidEnsures the component is in a usable state before interaction.Gets the component being tested.Gets the texts of the menu items, as the browser shows them.getItemTexts(String topLevelText, String... nestedItemsText) Gets the texts of the items of the sub menu of the item matching the given text, as the browser shows them.getItemTooltipText(int topLevelPosition, int... nestedItemsPositions) Gets the tooltip text of the menu item at the given position in the menu.getItemTooltipText(String topLevelText, String... nestedItemsText) Gets the tooltip text of the menu item matching the given text.booleanisItemChecked(int topLevelPosition, int... nestedItemsPositions) Checks if the checkable menu item at given position is checked.booleanisItemChecked(String topLevelText, String... nestedItemsText) Checks if the checkable menu item matching given text is checked.voidopen()Opens the context menu on the row it currently targets, as if the user had asked for it in the browser.voidopen(int row) Opens the context menu on the given row, as if the user had asked for it in the browser.voidOpens the context menu on the given row and column, as if the user had asked for it in the browser.Methods inherited from class com.vaadin.browserless.locator.Locator
atIndex, component, components, exists, inside, inside, invalidate, self, with, withAttribute, withAttribute, withClassName, withCondition, withId, withinSlot, withoutAttribute, withoutAttribute, withoutClassName, withTestIdMethods 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, click, middleClick, middleClick, rightClick, rightClick
-
Constructor Details
-
GridContextMenuLocator
-
-
Method Details
-
getComponent
Description copied from interface:ClickableGets the component being tested.- Specified by:
getComponentin interfaceClickable<Y>- Returns:
- the component under test
-
ensureComponentIsUsable
public void ensureComponentIsUsable()Description copied from interface:ClickableEnsures the component is in a usable state before interaction.- Specified by:
ensureComponentIsUsablein interfaceClickable<Y>
-
open
public void open()Opens the context menu on the row it currently targets, as if the user had asked for it in the browser. The target row is the one given toGridTester.contextMenu(int), so this method is the counterpart of that entry point. Useopen(int)to open the menu on a row directly. It does not render any client-side overlay, it only simulates the server-side state changes that opening the menu produces: the menu is attached to the UI, so its items become findable and clickable, and aGridContextMenuOpenedEventreporting the target row is fired. Javadoc copied fromGridContextMenuTester.open().- Throws:
IllegalStateException- if the menu does not target a row, if it is already open, or if a dynamic content handler prevented it from opening
-
open
public void open(int row) Opens the context menu on the given row, as if the user had asked for it in the browser. The index is 0 based and counts the rows the user sees. The row is reported by the events the menu fires, soGridContextMenuItemClickEvent.getItem()andGridContextMenuOpenedEvent.getItem()hold the item on that row. Javadoc copied fromGridContextMenuTester.open(int).- Parameters:
row- row to open the menu on- Throws:
IllegalStateException- if the menu is already open, or if a dynamic content handler prevented it from openingIndexOutOfBoundsException- if the grid has no such row
-
open
Opens the context menu on the given row and column, as if the user had asked for it in the browser. The column is reported byGridContextMenuOpenedEvent.getColumnId(). Javadoc copied fromGridContextMenuTester.open(int,java.lang.String).- Parameters:
row- row to open the menu on, 0 basedcolumnKey- key of the column to open the menu on, as set withGrid.Column.setKey(String)- Throws:
IllegalArgumentException- if the grid has no column with the given keyIllegalStateException- if the column is not visible, if the menu is already open, or if a dynamic content handler prevented it from openingIndexOutOfBoundsException- if the grid has no such row
-
close
public void close()Closes the context menu. Javadoc copied fromGridContextMenuTester.close().- Throws:
IllegalStateException- if the menu is not open
-
clickItem
Simulates a click on the item that matches the given text. For a 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. If there are multiple visible items at the same level with the same text, anIllegalStateExceptionis thrown because the target is ambiguous. Disabled or invisible items cannot be clicked and will also cause anIllegalStateException. The menu has to be open, since its items are not part of the UI before that. Javadoc copied fromGridContextMenuTester.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 menu is not open, if there are multiple visible matching items at any level, or if the item at the given path is disabled or not visible.
-
clickItem
public void clickItem(int topLevelPosition, int... nestedItemsPositions) Simulates a click on the item at the given position in the menu. For a nested menu item, provide the position of each sub menu that should be navigated to reach the requested item. Positions are zero-based and refer only to items that are visible at each menu level, i.e. hidden items are ignored (the same way as in the browser). Disabled or invisible items cannot be clicked and will cause anIllegalStateException. The menu has to be open, since its items are not part of the UI before that. Javadoc copied fromGridContextMenuTester.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 menu is not open, or if the item at the given position is disabled or not visible.
-
isItemChecked
Checks if the checkable menu item matching given text is checked. For a nested menu item, provide the text of each menu item in the hierarchy. Javadoc copied fromGridContextMenuTester.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 menu is not open, or 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 a nested menu item, provide the position of each sub menu that should be navigated to reach the requested item. Javadoc copied fromGridContextMenuTester.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- Returns:
- true if the item at given position is checked, otherwise false.
- Throws:
IllegalArgumentException- if the provided position does not identify a menu item or if the menu item is not checkable.IllegalStateException- if the menu is not open, or if the item at given position is not usable.
-
getItemTooltipText
Gets the tooltip text of the menu item matching the given text. For a nested menu item, provide the text of each menu item in the hierarchy. Javadoc copied fromGridContextMenuTester.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 menu is not open, or if the item at given path is not usable.
-
getItemTooltipText
Gets the tooltip text of the menu item at the given position in the menu. For a nested menu item, provide the position of each sub menu that should be navigated to reach the requested item. Javadoc copied fromGridContextMenuTester.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 menu is not open, or if the item at given position is not usable.
-
getItemTexts
Gets the texts of the menu items, as the browser shows them. Hidden items are ignored, so the returned texts are aligned with the positions used byclickItem(int, int...). A text can also be given toclickItem(String, String...), as long as it identifies a single enabled item: a text that several visible items share is ambiguous, and a disabled item cannot be clicked. An item created from a component has no text of its own, and is reported as an empty string. Useto reach such an item. The menu has to be open, since its items are not part of the UI before that. The items are the ones the menu offers for the row it was opened on, so a dynamic content handler has run by then.invalid reference
#find(Class)
Javadoc copied frommenu.addItem("Edit", event -> { }); menu.addItem("Hidden", event -> { }).setVisible(false); menu.addItem("Share"); tester.open(0); // ["Edit", "Share"] tester.getItemTexts();GridContextMenuTester.getItemTexts().- Returns:
- the texts of the visible top level menu items, in the order they are shown in
- Throws:
IllegalStateException- if the menu is not open, or is not visible
-
getItemTexts
Gets the texts of the items of the sub menu of the item matching the given text, as the browser shows them. For a nested sub menu, provide the text of each menu item in the hierarchy, the same way as inclickItem(String, String...). Hidden items are ignored at every level, both when following the path and in the returned texts. The menu has to be open, since its items are not part of the UI before that.
Javadoc copied fromvar subMenu = menu.addItem("Share").getSubMenu(); subMenu.addItem("Copy link", event -> { }); subMenu.addItem("Email", event -> { }); tester.open(0); // ["Copy link", "Email"] tester.getItemTexts("Share");GridContextMenuTester.getItemTexts(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 texts of the visible items of the sub menu, in the order they are shown in
- Throws:
IllegalArgumentException- if the provided text does not identify a menu item, or if the item at the given path has no sub menu.IllegalStateException- if the menu is not open or not visible, if there are multiple matching items at any level, or if the item at the given path is disabled or not visible.
-