com.vaadin.flow.component.grid.testbench.
Class GridElement
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
Direct Known Subclasses:
A TestBench element representing a <vaadin-grid>
element.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Click select all check box
void
deselect
(int rowIndex) Deselects the row with the given index.
protected void
Gets all columns defined for the grid, including any selection checkbox column.
getCell
(int rowIndex, int colIndex) Gets the grid cell for the given row and column index.
getCell
(int rowIndex, GridColumnElement column) Gets the grid cell for the given row and column.
Finds the first cell inside the rendered range with a text content matching the given string.
getCells
(int rowIndex) Gets the grid cells for the given row.
getCells
(int rowIndex, GridColumnElement... columnElements) Gets the grid cells for the given row and column elements.
Gets the column with the given header text.
Gets the empty state content.
int
Gets the index of the first row which is at least partially visible.
getFooterCell
(int columnIndex) Gets the footer cell for the given visible column index.
getHeaderCell
(int columnIndex) Gets the header cell for the given visible column index.
getHeaderCellContent
(int rowIndex, int columnIndex) Finds the vaadin-grid-cell-content element for the given row and column in header.
int
Gets the index of the last row which is at least partially visible.
int
Gets the page size used when fetching data.
getRow
(int rowIndex) Gets the
tr
element for the given row index.int
Gets the total number of rows.
getRows
(int firstRowIndex, int lastRowIndex) Gets the rows (present in the DOM) specified by the lower and upper row indexes.
Gets the currently visible columns in the grid, including any selection checkbox column.
Gets all the currently visible rows.
protected boolean
protected void
scrollToFlatRow
(int row) Scrolls to the row with the given flat row index.
void
scrollToRow
(int row) Scrolls to the row with the given index.
void
select
(int rowIndex) Selects the row with the given index.
protected void
Methods 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, getClassNames, getCommandExecutor, getContext, getCssValue, getDriver, getLocation, getProperty, getPropertyBoolean, getPropertyDouble, getPropertyElement, getPropertyElements, getPropertyInteger, getPropertyString, getRect, getScreenshotAs, getSize, getTagName, getText, getWrappedElement, hasAttribute, hasClassName, hashCode, init, init, isChrome, isDisplayed, isEnabled, isFirefox, isSelected, scroll, scrollIntoView, scrollLeft, sendKeys, setProperty, setProperty, setProperty, setProperty, submit, waitForVaadin, waitUntil, waitUntil, wrap, wrapElement, wrapElements
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.testbench.HasElementQuery
$, $
Methods inherited from interface org.openqa.selenium.WebElement
getAccessibleName, getAriaRole, getDomAttribute, getDomProperty, getShadowRoot
-
Constructor Details
-
GridElement
public GridElement()
-
-
Method Details
-
waitUntilLoadingFinished
protected void waitUntilLoadingFinished() -
isLoading
protected boolean isLoading() -
scrollToRow
public void scrollToRow(int row) Scrolls to the row with the given index.
Parameters:
row
- the row to scroll to -
scrollToFlatRow
protected void scrollToFlatRow(int row) Scrolls to the row with the given flat row index.
Parameters:
row
- the row to scroll to -
getPageSize
public int getPageSize()Gets the page size used when fetching data.
Returns:
the page size
-
getFirstVisibleRowIndex
public int getFirstVisibleRowIndex()Gets the index of the first row which is at least partially visible.
Returns:
the index of the first visible row, -1 if Grid is empty
-
getRowCount
public int getRowCount()Gets the total number of rows.
Returns:
the number of rows
-
getCell
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
Parameters:
rowIndex
- the row indexcolIndex
- the column indexReturns:
the grid cell for the given coordinates
-
getCell
Gets the grid cell for the given row and column.
Automatically scrolls the given row into view
Parameters:
rowIndex
- the row indexcolumn
- the column element for the columnReturns:
the grid cell for the given coordinates
-
getCell
Finds the first cell inside the rendered range with a text content matching the given string.
Parameters:
contents
- the string to look forReturns:
a grid cell containing the given string
Throws:
org.openqa.selenium.NoSuchElementException
- if no cell with the given string was found -
getLastVisibleRowIndex
public int getLastVisibleRowIndex()Gets the index of the last row which is at least partially visible.
Returns:
the index of the last visible row, -1 if Grid is empty
-
getRows
public List<GridTRElement> getRows(int firstRowIndex, int lastRowIndex) throws IndexOutOfBoundsException Gets the rows (present in the DOM) specified by the lower and upper row indexes.
Parameters:
firstRowIndex
- the lower row index to be retrieved (inclusive)lastRowIndex
- the upper row index to be retrieved (inclusive)Returns:
a
GridTRElement
list with the rows contained between the given coordinates.Throws:
IndexOutOfBoundsException
- if either of the provided row indexes do not exist -
getRow
Gets the
tr
element for the given row index.Parameters:
rowIndex
- the row indexReturns:
the tr element for the row
Throws:
IndexOutOfBoundsException
- if no row with given index exists -
getAllColumns
Gets all columns defined for the grid, including any selection checkbox column.
Returns:
a list of grid column elements which can be used to refer to the given column
-
generatedColumnIdsIfNeeded
protected void generatedColumnIdsIfNeeded() -
getVisibleColumns
Gets the currently visible columns in the grid, including any selection checkbox column.
Returns:
a list of grid column elements which can be used to refer to the given column
-
getColumn
public GridColumnElement getColumn(String headerText) throws org.openqa.selenium.NoSuchElementException Gets the column with the given header text.
If multiple columns are found with the same header text, returns the first column.
Parameters:
headerText
- the text in the headerReturns:
the grid column element for the given column
Throws:
org.openqa.selenium.NoSuchElementException
- if no column was found -
getHeaderCell
Gets the header cell for the given visible column index.
Parameters:
columnIndex
- the index of the columnReturns:
a cell element for the header cell
-
getHeaderCellContent
Finds the vaadin-grid-cell-content element for the given row and column in header.
Parameters:
rowIndex
- the index of the row in the headercolumnIndex
- the index of the column in the headerReturns:
the vaadin-grid-cell-content element for the given row and column in header.
-
select
public void select(int rowIndex) Selects the row with the given index.
Parameters:
rowIndex
- the row to select -
deselect
public void deselect(int rowIndex) Deselects the row with the given index.
Parameters:
rowIndex
- the row to deselect -
clickSelectAll
public void clickSelectAll()Click select all check box
-
getVisibleRows
Gets all the currently visible rows.
Returns:
a
GridTRElement
list representing the currently visible rows. -
getCells
Gets the grid cells for the given row and column elements.
Parameters:
rowIndex
- the row indexcolumnElements
- the column elementsReturns:
a
GridTHTDElement
list with the cells for the given coordinates. -
getCells
Gets the grid cells for the given row.
Parameters:
rowIndex
- the row indexReturns:
a
GridTHTDElement
list with the cells for the given coordinates. -
getEmptyStateContent
Gets the empty state content.
Returns:
the empty state content
Throws:
org.openqa.selenium.NoSuchElementException
- if no empty state content was found
-