Skip to main content

GridElement

Playwright element wrapper for <vaadin-grid> providing helpers for scrolling, querying visible rows, accessing cell content, and interacting with the grid’s header, body, and selection.

Component Tag

vaadin-grid

Implements

  • FocusableElement - Focus management
  • HasStyleElement - CSS class and style management
  • HasThemeElement - Theme variant support
  • HasEnabledElement - Enable/disable state

Constructor

Locator
required
Playwright locator for the <vaadin-grid> element

Static Factory Methods

get

Get the first grid on the page or within a parent locator.
Page
Playwright page
Locator
Parent locator to search within

getById

Get a grid by its id attribute.
Page
Playwright page
String
Element id

Row and Column Methods

getTotalRowCount

Get the total number of rows (data items) in the grid.

getRenderedRowCount

Get the number of rows currently rendered in the DOM (may be less than total due to virtualization).

getColumnCount

Get the number of visible (non-hidden) columns.

isAllRowsVisible

Whether the grid has allRowsVisible enabled.

Header Methods

findHeaderCell

Find a header cell by column index.
int
0-based header row index (default 0)
int
0-based visible column index

findHeaderCellByText

Find a header cell by its text content.
int
0-based header row index (default 0)
String
Header text to find

getHeaderCellContents

Get the text content of all visible header cells.
Returns a list of header cell text contents.

Cell Access Methods

findCell

Find a body cell by row and column index, or by row index and column header text.
int
0-based row index
int
0-based column index
String
Header text of the column

findRow

Find a row by its index (scrolls if necessary).
int
0-based row index
Returns a RowElement wrapper providing cell access and selection methods.

findRowIndexesWithColumnText

Find row indexes where the cell in the given column has the given text.
int
Column index to check
String
Text to match

Scroll Methods

scrollToRow

Scroll the grid so the given row index becomes visible.
int
0-based row index

scrollToStart

Scroll to the very beginning of the grid.

scrollToEnd

Scroll to the very end of the grid.

Selection Methods

select

Select a row by index.
int
Row index to select

deselect

Deselect a row by index.
int
Row index to deselect

getSelectedItemCount

Get the number of currently selected items.

checkSelectAll

Check the select-all checkbox.

uncheckSelectAll

Uncheck the select-all checkbox.

isSelectAllChecked

Check if the select-all checkbox is checked.

isSelectAllIndeterminate

Check if the select-all checkbox is indeterminate.

Utility Methods

waitForGridToStopLoading

Wait for the grid to finish loading after a scroll or other action.

Inner Classes

CellElement

Represents a cell in the grid.

Methods

  • Locator getTableCellLocator() - Get the table cell (td or th) locator
  • int getColumnIndex() - Get the 0-based column index
  • Locator getCellContentLocator() - Get the cell content locator
  • String getContentSlotName() - Get the slot name for cell content
  • void click() - Click the cell content

HeaderCellElement

Extends CellElement for header cells with sorting support.

Methods

  • boolean isSortable() - Whether the header supports sorting
  • void clickSort() - Click to sort the column
  • boolean isSortAscending() - Whether sorted ascending
  • boolean isSortDescending() - Whether sorted descending
  • boolean isNotSorted() - Whether not sorted

RowElement

Represents a row in the grid.

Methods

  • Locator getRowLocator() - Get the row (tr) locator
  • int getRowIndex() - Get the 0-based row index
  • CellElement getCell(int columnIndex) - Get cell by column index
  • CellElement getCell(String columnHeaderText) - Get cell by header text
  • CellElement getDetailsCell() - Get the details cell
  • boolean isSelected() - Whether the row is selected
  • void select() - Select the row
  • void deselect() - Deselect the row
  • void openDetails() - Open row details
  • void closeDetails() - Close row details
  • boolean isDetailsOpen() - Whether details are open

Usage Examples

Basic Grid Operations

Access Headers

Access Cell Content

Work with Rows

Sorting

Scroll to Distant Row

Selection Operations