Class TreeGridElement
- All Implemented Interfaces:
CanCompareScreenshots,HasCallFunction,HasDriver,HasElementQuery,HasPropertySettersGetters,HasSearchContext,HasTestBenchCommandExecutor,org.openqa.selenium.SearchContext,org.openqa.selenium.TakesScreenshot,org.openqa.selenium.WebElement,org.openqa.selenium.WrapsElement
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcollapseWithClick(int rowFlatIndex) Collapses the row at the given index in the grid.voidcollapseWithClick(int rowFlatIndex, int hierarchyColumnIndex) Collapses the row at the given index in the grid with the given hierarchical column index.voidexpandWithClick(int rowFlatIndex) Expands the row at the given index in the grid.voidexpandWithClick(int rowFlatIndex, int hierarchyColumnIndex) Expands the row at the given index in the grid with the given hierarchical column index.getCellWaitForRow(int rowFlatIndex, int colIndex) Gets the grid cell for the given row and column index.getCellWaitForRow(int rowFlatIndex, GridColumnElement column) Gets the grid cell for the given row and column.org.openqa.selenium.WebElementgetExpandToggleElement(int rowFlatIndex, int hierarchyColumnIndex) Gets the 'vaadin-grid-tree-toggle' element for the given row.intGets the total number of rows currently known to TreeGrid.booleanhasExpandToggle(int rowFlatIndex, int hierarchyColumnIndex) Check whether the given indices correspond to a cell that contains a visible hierarchy toggle element.booleanhasRow(int rowFlatIndex) Returns true if given index has tr element for the rowbooleanisDetailsOpen(int rowFlatIndex) Returnstrueif details are open or the given row index.booleanisRowCollapsed(int rowFlatIndex, int hierarchyColumnIndex) Returns whether the row at the given index is collapsed or not.booleanisRowExpanded(int rowFlatIndex, int hierarchyColumnIndex) Returns whether the row at the given index is expanded or not.voidScrolls the TreeGrid to the end.voidscrollToFlatRowAndWait(int row) Deprecated, for removal: This API element is subject to removal in a future version.since 25.0, and will be removed in Vaadin 26.voidscrollToRow(int row) Deprecated.since 25.0.voidscrollToRowAndWait(int row) Deprecated, for removal: This API element is subject to removal in a future version.since 25.0 and will be removed in Vaadin 26.voidscrollToRowAndWait(int... indexes) Deprecated, for removal: This API element is subject to removal in a future version.since 25.0 and will be removed in Vaadin 26.voidscrollToRowByFlatIndex(int rowFlatIndex) Scrolls to a row at the given flat index, an index that represents the position across all rows, including children of expanded rows.intscrollToRowByPath(int... path) Scrolls to a row specified by the given hierarchical path and returns its flat index.Methods inherited from class com.vaadin.flow.component.grid.testbench.GridElement
clickSelectAll, deselect, generatedColumnIdsIfNeeded, getAllColumns, getCell, getCell, getCell, getCells, getCells, getColumn, getEmptyStateContent, getFirstVisibleRowIndex, getFooterCell, getFooterCell, getFooterCellContent, getHeaderCell, getHeaderCell, getHeaderCellContent, getLastVisibleRowIndex, getPageSize, getRow, getRow, getRows, getVisibleColumns, getVisibleRows, isLoading, select, waitUntilLoadingFinishedMethods inherited from class com.vaadin.testbench.TestBenchElement
callFunction, clear, click, click, compareScreen, compareScreen, compareScreen, contextClick, dispatchEvent, dispatchEvent, doubleClick, equals, executeScript, findElement, findElements, focus, getAttribute, getCapabilities, getChildren, getClassNames, getCommandExecutor, getContext, getCssValue, getDomAttribute, getDomProperty, getDriver, getId, getLocation, getParent, getProperty, getPropertyBoolean, getPropertyDouble, getPropertyElement, getPropertyElements, getPropertyInteger, getPropertyString, getRect, getScreenshotAs, getShadowRoot, getSize, getTagName, getText, getWrappedElement, hasAttribute, hasClassName, hashCode, hover, init, init, isChrome, isDisplayed, isEnabled, isFirefox, isFocused, isReadOnly, isSelected, scroll, scrollIntoView, scrollLeft, sendKeys, setProperty, setProperty, setProperty, setProperty, submit, waitForVaadin, waitUntil, waitUntil, wrap, wrapElement, wrapElementsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.testbench.HasElementQuery
$, $Methods inherited from interface org.openqa.selenium.WebElement
getAccessibleName, getAriaRole
-
Constructor Details
-
TreeGridElement
public TreeGridElement()
-
-
Method Details
-
scrollToRow
Deprecated.since 25.0. Please update your code to usescrollToRowByPath(int...)with a single index where you want to scroll to a root-level row. In Vaadin 26, this deprecated method will be changed to accept a flat index and behave asscrollToRowByFlatIndex(int), which may break tests if not updated.Scrolls to the row with the given index in the root level.- Overrides:
scrollToRowin classGridElement- Parameters:
row- the row to scroll to
-
scrollToRowAndWait
Deprecated, for removal: This API element is subject to removal in a future version.since 25.0 and will be removed in Vaadin 26. UsescrollToRowByPath(int...)with a single index instead.Scrolls to the row with the given index in the root level.- Parameters:
row- the row to scroll to
-
scrollToRowAndWait
Deprecated, for removal: This API element is subject to removal in a future version.since 25.0 and will be removed in Vaadin 26. UsescrollToRowByPath(int...)instead.Scrolls to the row with the given indexes. The indexes are hierarchical, starting with the root index.- Parameters:
indexes- the indexes of the row to scroll to
-
scrollToFlatRowAndWait
Deprecated, for removal: This API element is subject to removal in a future version.since 25.0, and will be removed in Vaadin 26. UsescrollToRowByFlatIndex(int)instead.Scrolls to the row with the given flat index.- Parameters:
row- the row to scroll to
-
scrollToRowByFlatIndex
public void scrollToRowByFlatIndex(int rowFlatIndex) Scrolls to a row at the given flat index, an index that represents the position across all rows, including children of expanded rows.This method works best with
HierarchyFormat#FLATTENEDdata providers, where the full hierarchy is known upfront and flat indexes remain stable during scrolling.When using
HierarchyFormat#NESTEDdata providers, the hierarchy is resolved lazily while scrolling, so flat indexes may shift as more levels are discovered. With these data providers, consider usingscrollToRowByPath(int...), which targets rows by their hierarchical path.- Parameters:
rowFlatIndex- the flat index of the row to scroll to
-
scrollToRowByPath
public int scrollToRowByPath(int... path) Scrolls to a row specified by the given hierarchical path and returns its flat index. The returned index can then be used with other methods, for exampleGridElement.getRow(int):int rowFlatIndex = treeGrid.scrollToRowByPath(2, 1); assertEquals("Row 2-1", treeGrid.getRow(rowFlatIndex).getText());The hierarchical path is an array of 0-based indexes, where each index refers to a child of the row at the previous index. Scrolling continues until it reaches the last index in the array or encounters a collapsed row.
For example, given
{ 2, 1, ... }as the path, this method will first try to scroll to the row at index 2 in the root level. If that row is expanded, it will then try to scroll to the row at index 1 among its children, and so forth.NOTE: This method works only with tree grids using data providers that return data in
HierarchyFormat#NESTED. ForHierarchyFormat#FLATTENEDdata providers, usescrollToRowByFlatIndex(int)with a flat index instead.- Parameters:
path- an array of indexes representing the path to the target row- Returns:
- the flat index of the row that was scrolled to
-
getCellWaitForRow
Gets the grid cell for the given row and column index.For the column index, only visible columns are taken into account.
Automatically scrolls the given row into view and waits for the row to load.
- Parameters:
rowFlatIndex- the flat index of the rowcolIndex- the column index- Returns:
- the grid cell for the given coordinates
-
getCellWaitForRow
Gets the grid cell for the given row and column.Automatically scrolls the given row into view and waits for the row to load.
- Parameters:
rowFlatIndex- the flat index of the rowcolumn- the column element for the column- Returns:
- the grid cell for the given coordinates
-
expandWithClick
public void expandWithClick(int rowFlatIndex) Expands the row at the given index in the grid. This expects the first column to have the hierarchy data.- Parameters:
rowFlatIndex- the flat index of the row to expand- See Also:
-
expandWithClick
public void expandWithClick(int rowFlatIndex, int hierarchyColumnIndex) Expands the row at the given index in the grid with the given hierarchical column index.- Parameters:
rowFlatIndex- the flat index of the row to expandhierarchyColumnIndex- the index of the hierarchy column
-
collapseWithClick
public void collapseWithClick(int rowFlatIndex) Collapses the row at the given index in the grid. This expects the first column to have the hierarchy data.- Parameters:
rowFlatIndex- the flat index of the row to collapse- See Also:
-
collapseWithClick
public void collapseWithClick(int rowFlatIndex, int hierarchyColumnIndex) Collapses the row at the given index in the grid with the given hierarchical column index.- Parameters:
rowFlatIndex- the flat index of the row to collapsehierarchyColumnIndex- the index of the hierarchy column
-
isRowExpanded
public boolean isRowExpanded(int rowFlatIndex, int hierarchyColumnIndex) Returns whether the row at the given index is expanded or not.- Parameters:
rowFlatIndex- the flat index of the rowhierarchyColumnIndex- the index of the hierarchy column- Returns:
trueif expanded,falseif collapsed
-
isRowCollapsed
public boolean isRowCollapsed(int rowFlatIndex, int hierarchyColumnIndex) Returns whether the row at the given index is collapsed or not.- Parameters:
rowFlatIndex- the flat index of the rowhierarchyColumnIndex- the index of the hierarchy column- Returns:
trueif collapsed,falseif expanded
-
hasExpandToggle
public boolean hasExpandToggle(int rowFlatIndex, int hierarchyColumnIndex) Check whether the given indices correspond to a cell that contains a visible hierarchy toggle element.- Parameters:
rowFlatIndex- the flat index of the rowhierarchyColumnIndex- the index of the hierarchy column- Returns:
trueif this cell has the expand toggle visible
-
getExpandToggleElement
public org.openqa.selenium.WebElement getExpandToggleElement(int rowFlatIndex, int hierarchyColumnIndex) Gets the 'vaadin-grid-tree-toggle' element for the given row.- Parameters:
rowFlatIndex- the flat index of the rowhierarchyColumnIndex- the index of the hierarchy column- Returns:
- the
spanelement that is clicked for expanding/collapsing a rows - Throws:
org.openqa.selenium.NoSuchElementException- if there is no expand element for this row
-
isDetailsOpen
public boolean isDetailsOpen(int rowFlatIndex) Returnstrueif details are open or the given row index.- Parameters:
rowFlatIndex- the flat index of the row- Returns:
trueif details are shown in the target row
-
hasRow
public boolean hasRow(int rowFlatIndex) Returns true if given index has tr element for the row- Parameters:
rowFlatIndex- the flat index of the row- Returns:
trueif there is tr element for the row,falseotherwise
-
getRowCount
public int getRowCount()Gets the total number of rows currently known to TreeGrid.This method returns the actual total number of rows across the entire expanded tree only when TreeGrid uses a
HierarchyFormat#FLATTENEDdata provider.For data providers that return data in
HierarchyFormat#NESTED, hierarchy levels are discovered lazily – only when they appear in the viewport, which makes it impossible to determine the total number of rows in advance. As a result, this method may return a lower number that will gradually increase as more expanded rows have been seen.- Overrides:
getRowCountin classGridElement- Returns:
- the number of rows
-
scrollToEnd
public void scrollToEnd()Scrolls the TreeGrid to the end.
-