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 rowIndex) Collapses the row at the given index in the grid.voidcollapseWithClick(int rowIndex, int hierarchyColumnIndex) Collapses the row at the given index in the grid with the given hierarchical column index.voidexpandWithClick(int rowIndex) Expands the row at the given index in the grid.voidexpandWithClick(int rowIndex, int hierarchyColumnIndex) Expands the row at the given index in the grid with the given hierarchical column index.getCellWaitForRow(int rowIndex, int colIndex) Gets the grid cell for the given row and column index.getCellWaitForRow(int rowIndex, GridColumnElement column) Gets the grid cell for the given row and column.org.openqa.selenium.WebElementgetExpandToggleElement(int rowIndex, int hierarchyColumnIndex) Gets the 'vaadin-grid-tree-toggle' element for the given row.longReturns a number of expanded rows in the grid element.intGets the total number of rows.booleanhasExpandToggle(int rowIndex, int hierarchyColumnIndex) Check whether the given indices correspond to a cell that contains a visible hierarchy toggle element.booleanhasRow(int row) Returns true if given index has tr element for the rowbooleanisDetailsOpen(int rowIndex) Returnstrueif details are open or the given row index.protected booleanbooleanReturns true if grid is loading expanded rows.booleanisRowCollapsed(int rowIndex, int hierarchyColumnIndex) Returns whether the row at the given index is collapsed or not.booleanisRowExpanded(int rowIndex, int hierarchyColumnIndex) Returns whether the row at the given index is expanded or not.voidScrolls the TreeGrid to the end.voidscrollToFlatRowAndWait(int row) Scrolls to the row with the given flat index.voidscrollToRowAndWait(int row) Scrolls to the row with the given index.voidscrollToRowAndWait(int... indexes) Scrolls to the row with the given indexes.Methods inherited from class com.vaadin.flow.component.grid.testbench.GridElement
clickSelectAll, deselect, generatedColumnIdsIfNeeded, getAllColumns, getCell, getCell, getCell, getCells, getCells, getColumn, getEmptyStateContent, getFirstVisibleRowIndex, getFooterCell, getHeaderCell, getHeaderCellContent, getLastVisibleRowIndex, getPageSize, getRow, getRow, getRows, getVisibleColumns, getVisibleRows, scrollToFlatRow, scrollToRow, 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
-
scrollToRowAndWait
public void scrollToRowAndWait(int row) Scrolls to the row with the given index.- Parameters:
row- the row to scroll to
-
scrollToRowAndWait
public void scrollToRowAndWait(int... indexes) 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
public void scrollToFlatRowAndWait(int row) Scrolls to the row with the given flat index.- Parameters:
row- the row to scroll 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:
rowIndex- the row indexcolIndex- 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:
rowIndex- the row indexcolumn- the column element for the column- Returns:
- the grid cell for the given coordinates
-
expandWithClick
public void expandWithClick(int rowIndex) Expands the row at the given index in the grid. This expects the first column to have the hierarchy data.- Parameters:
rowIndex- 0-based row index to expand- See Also:
-
expandWithClick
public void expandWithClick(int rowIndex, int hierarchyColumnIndex) Expands the row at the given index in the grid with the given hierarchical column index.- Parameters:
rowIndex- 0-based row index to expandhierarchyColumnIndex- 0-based index of the hierarchy column
-
collapseWithClick
public void collapseWithClick(int rowIndex) Collapses the row at the given index in the grid. This expects the first column to have the hierarchy data.- Parameters:
rowIndex- 0-based row index to collapse- See Also:
-
collapseWithClick
public void collapseWithClick(int rowIndex, int hierarchyColumnIndex) Collapses the row at the given index in the grid with the given hierarchical column index.- Parameters:
rowIndex- 0-based row index to collapsehierarchyColumnIndex- 0-based index of the hierarchy column
-
isRowExpanded
public boolean isRowExpanded(int rowIndex, int hierarchyColumnIndex) Returns whether the row at the given index is expanded or not.- Parameters:
rowIndex- 0-based row indexhierarchyColumnIndex- 0-based index of the hierarchy column- Returns:
trueif expanded,falseif collapsed
-
isRowCollapsed
public boolean isRowCollapsed(int rowIndex, int hierarchyColumnIndex) Returns whether the row at the given index is collapsed or not.- Parameters:
rowIndex- 0-based row indexhierarchyColumnIndex- 0-based index of the hierarchy column- Returns:
trueif collapsed,falseif expanded
-
hasExpandToggle
public boolean hasExpandToggle(int rowIndex, int hierarchyColumnIndex) Check whether the given indices correspond to a cell that contains a visible hierarchy toggle element.- Parameters:
rowIndex- 0-based row indexhierarchyColumnIndex- 0-based index of the hierarchy column- Returns:
trueif this cell has the expand toggle visible
-
getExpandToggleElement
public org.openqa.selenium.WebElement getExpandToggleElement(int rowIndex, int hierarchyColumnIndex) Gets the 'vaadin-grid-tree-toggle' element for the given row.- Parameters:
rowIndex- 0-based row indexhierarchyColumnIndex- 0-based 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
-
getNumberOfExpandedRows
public long getNumberOfExpandedRows()Returns a number of expanded rows in the grid element. Notice that returned number does not mean that grid has yet finished rendering all visible expanded rows.- Returns:
- the number of expanded rows
-
isDetailsOpen
public boolean isDetailsOpen(int rowIndex) Returnstrueif details are open or the given row index.- Parameters:
rowIndex- the 0-based row index- Returns:
trueif details are shown in the target row
-
hasRow
public boolean hasRow(int row) Returns true if given index has tr element for the row- Parameters:
row- the row index- Returns:
trueif there is tr element for the row,falseotherwise
-
isLoadingExpandedRows
public boolean isLoadingExpandedRows()Returns true if grid is loading expanded rows.- Returns:
trueif grid is loading expanded rows,falseotherwise
-
isLoading
protected boolean isLoading()- Overrides:
isLoadingin classGridElement
-
getRowCount
public int getRowCount()Gets the total number of rows.Note that for TreeGrid this does not return reliable results if rows are expanded. Due to the lazy-loading nature of the grid, children of expanded rows are only loaded into the grid when they are scrolled into view. Likewise, they are removed again from the grid at some point when they are scrolled out of view. These child rows then only count against the total row count while they are loaded into the grid. Effectively, that means that the total row count will depend on the scroll position of the grid.
We are looking into making this more reliable by adding additional APIs to TreeGrid that would allow the component to keep track of the total number of rows just based on the expanded rows, and regardless of the scroll position. Please see this issue for more details.
- Overrides:
getRowCountin classGridElement- Returns:
- the number of rows
-
scrollToEnd
public void scrollToEnd()Scrolls the TreeGrid to the end.
-