Skip to main content

VirtualListElement

Playwright element wrapper for <vaadin-virtual-list> providing a virtualized scrollable list that lazily renders items as the user scrolls.

Component Tag

vaadin-virtual-list

Implements

  • FocusableElement - Focus management
  • HasStyleElement - CSS class and style management

Constructor

Locator
required
Playwright locator for the <vaadin-virtual-list> element

Static Factory Methods

get

Get the first virtual list on the page.
Page
Playwright page

Property Methods

getRowCount

Get the total number of items in the list.
Returns total item count (including items not yet rendered).

getFirstVisibleRowIndex

Get the index of the first row that is at least partially visible.
Returns 0-based index of the first visible row.

getLastVisibleRowIndex

Get the index of the last row that is at least partially visible.
Returns 0-based index of the last visible row.

getVisibleRowCount

Get the number of currently visible rows.
Returns count of rows visible in the viewport.

isRowInView

Whether the given row index is currently visible in the viewport.
int
0-based row index to check

Item Query Methods

getRenderedItems

Get a locator matching all currently rendered child elements.

getItemByIndex

Get the rendered DOM element at the given virtual index.
int
0-based virtual row index (must be currently in view)

getItemByText

Get a rendered item containing the given text.
String
Text to search for

Component Query Methods

getItemComponent

Get a typed component element from the rendered item at the given virtual index.
int
0-based virtual row index (must be in view)
Class<T>
Element class (e.g., ButtonElement.class)

getItemComponentByText

Get a typed component element from the rendered item whose text matches.
String
Text used to locate the item
Class<T>
Element class (e.g., ButtonElement.class)

getComponent

Get the first typed component element found anywhere in the currently rendered items.
Class<T>
Element class (e.g., ButtonElement.class)

Scroll Methods

scrollToRow

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

scrollToStart

Scroll to the very beginning of the list.

scrollToEnd

Scroll to the very end of the list.

Assertion Methods

assertRowCount

Assert the total number of items matches the expected count.
int
Expected row count

assertRowInView

Assert that the given row index is currently visible.
int
0-based row index

assertRowNotInView

Assert that the given row index is NOT currently visible.
int
0-based row index

assertFirstVisibleRow

Assert that the first visible row index equals the expected value.
int
Expected first visible row index

assertLastVisibleRow

Assert that the last visible row index equals the expected value.
int
Expected last visible row index

assertItemRendered

Assert that an item containing the given text is currently rendered.
String
Text to look for

assertEmpty

Assert the list has zero items.

Usage Examples

Basic Virtual List Operations

Scroll and Check Visibility

Access Item Content

Work with Components in Items

Scroll to Specific Position

Assert List State

Check Rendered Items