Class TreeGridLocator<Y>
- All Implemented Interfaces:
Clickable<TreeGrid<Y>>,HasThemeFilter<TreeGrid<Y>,TreeGridLocator<Y>>
TreeGrid, derived from
TreeGridTester. 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclickRow(int row) Click on grid row.voidClick on grid row with given meta keys pressed.voidclickRow(int row, MouseButton button) Click on grid row with given button.voidclickRow(int row, MouseButton button, MetaKeys metaKeys) Click on grid row with given button and meta keys pressed.voidcollapse(int row) Collapses the node on the given row, as if the user clicked its collapse toggle in the browser.contextMenu(int row) Gets a tester for the context menu of this grid, targeting the given row.voiddeselect(int row) Deselect the item on given row.voidDeselect all items in grid, running the same code as when the select all checkbox is unchecked.voiddoubleClickRow(int row) Double-click on grid row.voiddoubleClickRow(int row, MetaKeys metaKeys) Double-click on grid row with given meta keys pressed.voiddoubleClickRow(int row, MouseButton button) Double-click on grid row with given button.voiddoubleClickRow(int row, MouseButton button, MetaKeys metaKeys) Double-click on grid row with given button and meta keys pressed.voidEnsures the component is in a usable state before interaction.voidexpand(int row) Expands the node on the given row, as if the user clicked its expand toggle in the browser.getCellComponent(int row, int column) Get the component the grid renders for the cell in the given position.getCellComponent(int row, String columnName) Get the component the grid renders for the cell in the given row of the column with the given key.getCellText(int row, int column) Get the text that is shown on the client for the cell in the given position.Gets the grid column by column property.intgetColumnPosition(String property) Get the column position by column property.Gets the component being tested.getFooterCell(int column) Deprecated.getHeaderCell(int column) Deprecated.Useorinvalid reference
Grid.Column#getHeaderText()invalid reference
Grid.Column#getHeaderComponent()<V> VgetLitRendererPropertyValue(int row, int column, String propertyName, Class<V> propertyClass) Get property value for item's LitRenderer in column.<V> VgetLitRendererPropertyValue(int row, String columnName, String propertyName, Class<V> propertyClass) Get property value for item's LitRenderer in column.getRow(int row) Get the item at the given row index.Get selected items.getSortDirection(int column) Gets the current sort direction for column at the given index.getSortDirection(String property) Gets the current sort direction for column corresponding to the at the given property.booleanhasChildren(int row) Checks whether the node on the given row has children, meaning the user is shown an expand toggle for it.voidinvokeLitRendererFunction(int row, int column, String functionName) Invoke named function for item's LitRenderer in column.voidinvokeLitRendererFunction(int row, int column, String functionName, tools.jackson.databind.node.ArrayNode jsonArray) Invoke named function for item's LitRenderer in column using the supplied JSON arguments.voidinvokeLitRendererFunction(int row, String columnName, String functionName) Invoke named function for item's LitRenderer in column.voidinvokeLitRendererFunction(int row, String columnName, String functionName, tools.jackson.databind.node.ArrayNode jsonArray) Invoke named function for item's LitRenderer in column using the supplied JSON arguments.booleanisColumnSortable(int column) Checks if the column at the given index is sortable.booleanisColumnSortable(String property) Checks if the column for the given property is sortable.booleanisExpanded(int row) Checks whether the node on the given row is expanded.renderCellComponent(int row, int column) Render the component for the cell in the given position on its own, without the grid, and attach it to the grid so that it can be used.renderCellComponent(int row, String columnName) Render the component for the cell in the given row of the column with the given key on its own, without the grid, and attach it to the grid so that it can be used.voidselect(int row) Select the item on given row.voidSelect all items in grid, running the same code as when the select all checkbox is checked.intsize()Get the amount of items in the grid.voidsortByColumn(int column) Sorts the grid according to the given column sort status, as if the column header is pressed in the browser.voidsortByColumn(int column, SortDirection direction) Sorts the grid by the given column and sort direction, as if the column header is pressed in the browser until the requested direction is reached.voidsortByColumn(String property) Sorts the grid according to sort status ot the column identified by the given property, as if the column header is pressed in the browser.voidsortByColumn(String property, SortDirection direction) Sorts the grid by the given column and sort direction, as if the column header is pressed in the browser until the requested direction is reached.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, rightClickMethods inherited from interface com.vaadin.browserless.locator.HasThemeFilter
withoutTheme, withoutTheme, withTheme, withTheme
-
Constructor Details
-
TreeGridLocator
-
TreeGridLocator
-
-
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>
-
expand
public void expand(int row) Expands the node on the given row, as if the user clicked its expand toggle in the browser. The index is 0 based and counts only rows that are currently displayed, so children of collapsed nodes are skipped. The resultingExpandEventreportsComponentEvent.isFromClient()as true. Javadoc copied fromTreeGridTester.expand(int).- Parameters:
row- row of the node to expand- Throws:
IllegalStateException- if the component is not usable, if the tree grid has no visible hierarchy column, if the row has no children and thus no expand toggle, or if the node is already expanded
-
collapse
public void collapse(int row) Collapses the node on the given row, as if the user clicked its collapse toggle in the browser. The index is 0 based and counts only rows that are currently displayed, so children of collapsed nodes are skipped. The resultingCollapseEventreportsComponentEvent.isFromClient()as true. Javadoc copied fromTreeGridTester.collapse(int).- Parameters:
row- row of the node to collapse- Throws:
IllegalStateException- if the component is not usable, if the tree grid has no visible hierarchy column, if the row has no children and thus no collapse toggle, or if the node is not expanded
-
isExpanded
public boolean isExpanded(int row) Checks whether the node on the given row is expanded. The index is 0 based and counts only rows that are currently displayed, so children of collapsed nodes are skipped. Javadoc copied fromTreeGridTester.isExpanded(int).- Parameters:
row- row to check- Returns:
- true if the node on the row is expanded, otherwise false
- Throws:
IllegalStateException- if the component is not visible
-
hasChildren
public boolean hasChildren(int row) Checks whether the node on the given row has children, meaning the user is shown an expand toggle for it. The index is 0 based and counts only rows that are currently displayed, so children of collapsed nodes are skipped. Javadoc copied fromTreeGridTester.hasChildren(int).- Parameters:
row- row to check- Returns:
- true if the node on the row has children, otherwise false
- Throws:
IllegalStateException- if the component is not visible
-
getCellText
Get the text that is shown on the client for the cell in the given position. A hierarchy column added withTreeGrid.addHierarchyColumn(com.vaadin.flow.function.ValueProvider)renders the item through avaadin-grid-tree-toggle, so its text is read from the toggle's own value provider rather than from a column path. Every other column is read exactly asdoes. Javadoc copied frominvalid reference
GridTesterTreeGridTester.getCellText(int,int).- Parameters:
row- row of cellcolumn- column of cell- Returns:
- cell content that is sent to the client
- Throws:
IllegalStateException- if component is not visible
-
size
public int size()Get the amount of items in the grid. Javadoc copied fromGridTester.size().- Returns:
- items in grid
-
getRow
Get the item at the given row index. The index is 0 based. Javadoc copied fromGridTester.getRow(int).- Parameters:
row- row index of to get- Returns:
- grid item on row
-
clickRow
public void clickRow(int row) Click on grid row. The index is 0 based. Javadoc copied fromGridTester.clickRow(int).- Parameters:
row- row to click
-
clickRow
Click on grid row with given button. The index is 0 based. Javadoc copied fromGridTester.clickRow(int,com.vaadin.browserless.MouseButton).- Parameters:
row- row to clickbutton- MouseButton that was clicked- See Also:
-
clickRow
Click on grid row with given meta keys pressed. The index is 0 based. Javadoc copied fromGridTester.clickRow(int,com.vaadin.browserless.MetaKeys).- Parameters:
row- row to clickmetaKeys- meta key statuses for click
-
clickRow
Click on grid row with given button and meta keys pressed. The index is 0 based. Javadoc copied fromGridTester.clickRow(int,com.vaadin.browserless.MouseButton,com.vaadin.browserless.MetaKeys).- Parameters:
row- row to clickbutton- MouseButton that was clickedmetaKeys- meta key statuses for click- See Also:
-
doubleClickRow
public void doubleClickRow(int row) Double-click on grid row. The index is 0 based. Javadoc copied fromGridTester.doubleClickRow(int).- Parameters:
row- row to click
-
doubleClickRow
Double-click on grid row with given button. The index is 0 based. Javadoc copied fromGridTester.doubleClickRow(int,com.vaadin.browserless.MouseButton).- Parameters:
row- row to clickbutton- MouseButton that was clicked- See Also:
-
doubleClickRow
Double-click on grid row with given meta keys pressed. The index is 0 based. Javadoc copied fromGridTester.doubleClickRow(int,com.vaadin.browserless.MetaKeys).- Parameters:
row- row to clickmetaKeys- meta key statuses for click
-
doubleClickRow
Double-click on grid row with given button and meta keys pressed. The index is 0 based. Javadoc copied fromGridTester.doubleClickRow(int,com.vaadin.browserless.MouseButton,com.vaadin.browserless.MetaKeys).- Parameters:
row- row to clickbutton- MouseButton that was clickedmetaKeys- meta key statuses for click- See Also:
-
select
public void select(int row) Select the item on given row. The index is 0 based. Single select will clear any old selections. Multi select will add to selection. Javadoc copied fromGridTester.select(int).- Parameters:
row- row to select- Throws:
IllegalStateException- if not usable
-
selectAll
public void selectAll()Select all items in grid, running the same code as when the select all checkbox is checked. Only works for multi select, and only when the select all checkbox is actually shown - if it isn't, the user has no way to trigger this. Javadoc copied fromGridTester.selectAll().- Throws:
IllegalStateException- if not usable, not multi select or the select all checkbox is hidden
-
deselect
public void deselect(int row) Deselect the item on given row. The index is 0 based. Simulates the user deselecting a row: ctrl-clicking a selected row or unchecking the row's selection checkbox in multi select, clicking the selected row in single select. The row has to be selected. Deselecting a row that isn't selected is not a gesture the user has, so it fails instead of doing nothing. The call is ignored, exactly as the user's click would be, when the item is not selectable or when the grid is single select and deselecting is not allowed. Javadoc copied fromGridTester.deselect(int).- Parameters:
row- row to deselect- Throws:
IllegalStateException- if not usable, if the row is not selected or if the grid doesn't support selection
-
deselectAll
public void deselectAll()Deselect all items in grid, running the same code as when the select all checkbox is unchecked. Only works for multi select, and only when the select all checkbox is actually shown - if it isn't, the user has no way to trigger this. This is the counterpart ofselectAll()and behaves like the checkbox does: the selection is dropped in one selection event, without the per row toggle events the user would cause by unchecking rows one by one. Calldeselect(int)per row to model that instead. Javadoc copied fromGridTester.deselectAll().- Throws:
IllegalStateException- if not usable, not multi select or the select all checkbox is hidden
-
getCellComponent
Get the component the grid renders for the cell in the given position.A component renderer only produces a component when the grid renders a row for the client, so a renderer component is never part of the component tree that
find(...)walks, and this method is the way to reach it. What comes back is the very component the browser shows: asking for the same cell twice returns the same instance, and the instance is replaced when the grid re-renders the row, for example afterrefreshItem(...). A row the client has not asked for yet is scrolled into view first, the way a user reaches it.Use
renderCellComponent(int, int)to render a cell on its own, without the grid. Javadoc copied fromGridTester.getCellComponent(int,int).- Parameters:
row- item rowcolumn- column to get- Returns:
- the component the grid rendered for the targeted cell
- Throws:
IllegalArgumentException- when the target column of the cell is not a component rendererIllegalStateException- when the grid renders no component for the cell
-
getCellComponent
Get the component the grid renders for the cell in the given row of the column with the given key.A component renderer only produces a component when the grid renders a row for the client, so a renderer component is never part of the component tree that
find(...)walks, and this method is the way to reach it. What comes back is the very component the browser shows: asking for the same cell twice returns the same instance, and the instance is replaced when the grid re-renders the row, for example afterrefreshItem(...). A row the client has not asked for yet is scrolled into view first, the way a user reaches it.Use
renderCellComponent(int, String)to render a cell on its own, without the grid. Javadoc copied fromGridTester.getCellComponent(int,java.lang.String).- Parameters:
row- item rowcolumnName- key/property of column- Returns:
- the component the grid rendered for the target cell
- Throws:
IllegalArgumentException- when column for property doesn't exist or the target column of the cell is not a component rendererIllegalStateException- when the grid renders no component for the cell, which is the case for a hidden column
-
renderCellComponent
Render the component for the cell in the given position on its own, without the grid, and attach it to the grid so that it can be used.This asks the column's component renderer for a component for the item on the row, which is not the instance the grid renders for the client: every call renders the cell again and attaches the new instance to the grid, so asking twice for the same cell leaves two instances behind and a later
find(...)reports both.Prefer
getCellComponent(int, int), which returns the component the browser shows. This method is for tests written against the older behaviour of that method. A column index addresses the visible columns, so the cells the grid renders nothing for, those of a hidden column, are only reachable throughrenderCellComponent(int, String). Javadoc copied fromGridTester.renderCellComponent(int,int).- Parameters:
row- item rowcolumn- column to render- Returns:
- a freshly rendered component for the targeted cell
- Throws:
IllegalArgumentException- when the target column of the cell is not a component renderer
-
renderCellComponent
Render the component for the cell in the given row of the column with the given key on its own, without the grid, and attach it to the grid so that it can be used.This asks the column's component renderer for a component for the item on the row, which is not the instance the grid renders for the client: every call renders the cell again and attaches the new instance to the grid, so asking twice for the same cell leaves two instances behind and a later
find(...)reports both.Prefer
getCellComponent(int, String), which returns the component the browser shows. This method is for the cases the grid does not render itself, such as a hidden column. Javadoc copied fromGridTester.renderCellComponent(int,java.lang.String).- Parameters:
row- item rowcolumnName- key/property of column- Returns:
- a freshly rendered component for the target cell
- Throws:
IllegalArgumentException- when column for property doesn't exist or the target column of the cell is not a component renderer
-
getLitRendererPropertyValue
public <V> V getLitRendererPropertyValue(int row, String columnName, String propertyName, Class<V> propertyClass) Get property value for item's LitRenderer in column. Javadoc copied fromGridTester.getLitRendererPropertyValue(int,java.lang.String,java.lang.String,java.lang.Class).- Type Parameters:
V- the type of the LitRenderer property- Parameters:
row- item rowcolumnName- key/property of columnpropertyName- the name of the LitRenderer propertypropertyClass- the class of the value of the LitRenderer property- Returns:
- value of renderer's property for the target cell
- Throws:
IllegalArgumentException- when column for property doesn't exist or the target column of the cell is not a LitRenderer or when the given type of the property does not match the actual property type
-
getLitRendererPropertyValue
public <V> V getLitRendererPropertyValue(int row, int column, String propertyName, Class<V> propertyClass) Get property value for item's LitRenderer in column. Javadoc copied fromGridTester.getLitRendererPropertyValue(int,int,java.lang.String,java.lang.Class).- Type Parameters:
V- the type of the LitRenderer property- Parameters:
row- item rowcolumn- column to getpropertyName- the name of the LitRenderer propertypropertyClass- the class of the value of the LitRenderer property- Returns:
- value of renderer's property for the target cell
- Throws:
IllegalArgumentException- when column for property doesn't exist or the target column of the cell is not a LitRenderer or when the given type of the property does not match the actual property type
-
invokeLitRendererFunction
public void invokeLitRendererFunction(int row, String columnName, String functionName, tools.jackson.databind.node.ArrayNode jsonArray) Invoke named function for item's LitRenderer in column using the supplied JSON arguments. Javadoc copied fromGridTester.invokeLitRendererFunction(int,java.lang.String,java.lang.String,tools.jackson.databind.node.ArrayNode).- Parameters:
row- item rowcolumnName- key/property of columnfunctionName- the name of the LitRenderer function to invokejsonArray- the arguments to pass to the function
-
invokeLitRendererFunction
Invoke named function for item's LitRenderer in column. Javadoc copied fromGridTester.invokeLitRendererFunction(int,java.lang.String,java.lang.String).- Parameters:
row- item rowcolumnName- key/property of columnfunctionName- the name of the LitRenderer function to invoke
-
invokeLitRendererFunction
public void invokeLitRendererFunction(int row, int column, String functionName, tools.jackson.databind.node.ArrayNode jsonArray) Invoke named function for item's LitRenderer in column using the supplied JSON arguments. Javadoc copied fromGridTester.invokeLitRendererFunction(int,int,java.lang.String,tools.jackson.databind.node.ArrayNode).- Parameters:
row- item rowcolumn- column to getfunctionName- the name of the LitRenderer function to invokejsonArray- the arguments to pass to the function
-
invokeLitRendererFunction
Invoke named function for item's LitRenderer in column. Javadoc copied fromGridTester.invokeLitRendererFunction(int,int,java.lang.String).- Parameters:
row- item rowcolumn- column to getfunctionName- the name of the LitRenderer function to invoke
-
getHeaderCell
Deprecated.Useorinvalid reference
Grid.Column#getHeaderText()invalid reference
Grid.Column#getHeaderComponent()Get content in header for given column. Javadoc copied fromGridTester.getHeaderCell(int).- Parameters:
column- column to get header for- Returns:
- header contents
- Throws:
IllegalStateException- if component is not visible
-
getColumnPosition
Get the column position by column property. Javadoc copied fromGridTester.getColumnPosition(java.lang.String).- Parameters:
property- the property name of the column, not null- Returns:
- int position of column
-
getColumn
Gets the grid column by column property. Javadoc copied fromGridTester.getColumn(java.lang.String).- Parameters:
property- the property name of the column, not null- Returns:
- Grid.Column for property
-
getSelected
Get selected items. Javadoc copied fromGridTester.getSelected().- Returns:
- selected items
-
isColumnSortable
public boolean isColumnSortable(int column) Checks if the column at the given index is sortable. The index is 0 based. Javadoc copied fromGridTester.isColumnSortable(int).- Parameters:
column- column index to check for sort feature- Returns:
- true if the column is sortable, otherwise false
- Throws:
IndexOutOfBoundsException- if column index is invalid
-
isColumnSortable
Checks if the column for the given property is sortable. Javadoc copied fromGridTester.isColumnSortable(java.lang.String).- Parameters:
property- the property name of the column, not null- Returns:
- true if the column is sortable, otherwise false
- Throws:
IllegalArgumentException- if property name does not identify a column
-
getSortDirection
Gets the current sort direction for column at the given index. Throws an exception if the column does not exist or is not sortable. Javadoc copied fromGridTester.getSortDirection(int).- Parameters:
column- column index to get sort direction- Returns:
- sort direction for the column, or null if grid is not sorted by given column
- Throws:
IllegalArgumentException- if the column at given index is not sortableIndexOutOfBoundsException- if column index is invalid
-
getSortDirection
Gets the current sort direction for column corresponding to the at the given property. Throws an exception if the column does not exist or is not sortable. Javadoc copied fromGridTester.getSortDirection(java.lang.String).- Parameters:
property- the property name of the column, not null- Returns:
- sort direction for the column, or null if grid is not sorted by given column
- Throws:
IllegalArgumentException- if property name does not identify a column or if the column is not sortable
-
sortByColumn
Sorts the grid by the given column and sort direction, as if the column header is pressed in the browser until the requested direction is reached. Throws an exception if the column is not sortable or not visible. Javadoc copied fromGridTester.sortByColumn(int,com.vaadin.flow.data.provider.SortDirection).- Parameters:
column- column indexdirection- sort direction
-
sortByColumn
public void sortByColumn(int column) Sorts the grid according to the given column sort status, as if the column header is pressed in the browser. Throws an exception if the column is not sortable or not visible. Javadoc copied fromGridTester.sortByColumn(int).- Parameters:
column- column index
-
sortByColumn
Sorts the grid according to sort status ot the column identified by the given property, as if the column header is pressed in the browser. Throws an exception if the column is not sortable or not visible. Javadoc copied fromGridTester.sortByColumn(java.lang.String).- Parameters:
property- the property name of the column, not null
-
sortByColumn
Sorts the grid by the given column and sort direction, as if the column header is pressed in the browser until the requested direction is reached. Throws an exception if the column is not sortable or not visible. Javadoc copied fromGridTester.sortByColumn(java.lang.String,com.vaadin.flow.data.provider.SortDirection).- Parameters:
property- the property name of the column, not nulldirection- sort direction
-
contextMenu
Gets a tester for the context menu of this grid, targeting the given row. The index is 0 based and counts the rows the user sees. The menu is not opened, so that assertions can be made on it first; open it with.invalid reference
GridContextMenuTester#open()var menu = test(grid).contextMenu(0); menu.open(); menu.clickItem("Edit");Javadoc copied fromGridTester.contextMenu(int).- Parameters:
row- row the context menu is about- Returns:
- a tester for the context menu of this grid, targeting the given row
- Throws:
IllegalStateException- if the grid is not usable, or if it has no context menu or more than one
-
invalid reference
invalid reference