Dynamic web table practice
Practice reading, sorting and editing tables, plus a virtualized table whose rows only exist while they are on screen. Open the admin orders table
Sortable, editable tableSort by any column. Edit a customer name with the pencil.
Built well
| ORD-1001 | Ada Park | Paid | $19.50 |
| ORD-1002 | Bo Chen | Refunded | $56.50 |
| ORD-1003 | Cal Diaz | Pending | $93.50 |
| ORD-1004 | Dee Evans | Shipped | $130.50 |
| ORD-1005 | Eli Fox | Paid | $167.50 |
| ORD-1006 | Fay Gold | Refunded | $204.50 |
| ORD-1007 | Gus Hale | Pending | $241.50 |
| ORD-1008 | Ivy Ito | Shipped | $278.50 |
| ORD-1009 | Jon Kerr | Paid | $315.50 |
| ORD-1010 | Kai Lund | Refunded | $352.50 |
| ORD-1011 | Lia Moss | Pending | $389.50 |
| ORD-1012 | Max Nori | Shipped | $26.50 |
Built to break
Virtualized table500 orders, but only the rows in view are in the DOM.
Built well
Built to break
Paginated tableFind INV-1010: it is not on the first page.
Built well
| Order | Customer | Status | Total |
|---|---|---|---|
| INV-1001 | Ada Park | Paid | $19.50 |
| INV-1002 | Bo Chen | Refunded | $56.50 |
| INV-1003 | Cal Diaz | Pending | $93.50 |
| INV-1004 | Dee Evans | Shipped | $130.50 |
Built to break
Table of duplicate valuesFind the run on Firefox in Austin. Most cells repeat.
Built well
| Run | OS | Browser | City | Country |
|---|---|---|---|---|
| DUP-1 | Windows | Chrome | Pune | India |
| DUP-2 | Windows | Firefox | Pune | India |
| DUP-3 | macOS | Chrome | Pune | India |
| DUP-4 | Windows | Chrome | Austin | USA |
| DUP-5 | Linux | Firefox | Pune | India |
| DUP-6 | Windows | Chrome | Pune | India |
| DUP-7 | macOS | Safari | Austin | USA |
| DUP-8 | Windows | Firefox | Austin | USA |
Built to break
Tasks: write a locator, get a grade
How to locate Web tables
Tables tempt you to count
The quickest locator for a cell is a position: the third row, the second cell. It works until the order changes, and table order changes all the time. A user sorts, a new record arrives, a filter is applied, or a release changes the default sort. On v2 this page reverses every table, so a positional locator that passed on v1 now reads a different order.
The fix is to find the record first and the cell second. Every row here carries a test id with its order number, and its accessible name includes that number too. Find the row by what identifies the record, then look inside that row for the cell, button or text you need.
Div grids look like tables but are not. They have no table roles, so getByRole('row') finds nothing and table-aware XPath such as //tr/td[2] matches nothing. The fragile table on this page is a div grid with generated class names, which leaves position and visible text as the only handles.
Paginated tables hide most of their rows. A test that expects a record on the first page breaks when sorting or new data pushes it to the second. Filter or sort first, or page until the record appears.
Virtualized tables render only what is on screen. Rows scrolled out of view are not hidden; they do not exist in the DOM. A test has to scroll the container until the row is rendered, and aria-rowindex tells it where it is in the full list.
What a stable locator looks like
Scope to the table, find the row by its record id or test id, then work inside that row. For sorting, check aria-sort on the column header rather than reading the values back. For virtualized tables, scroll the container and wait for the row to appear.
// Find the record, not the position
const row = page.getByTestId('orders-table').getByRole('row', { name: /ORD-1003/ });
await row.getByRole('button', { name: 'Edit customer for ORD-1003' }).click();
await page.getByLabel('Customer for ORD-1003').fill('Zed Young');
await page.getByRole('button', { name: 'Save' }).click();
await expect(row).toContainText('Zed Young');
await page.getByRole('button', { name: 'Total' }).click();
await expect(page.getByRole('columnheader', { name: /Total/ }))
.toHaveAttribute('aria-sort', 'ascending');
// Virtualized: scroll until the row exists
await page.getByTestId('virtual-table').evaluate((el) => { el.scrollTop = 40 * 300; });
await expect(page.getByTestId('vrow-ORD-1301')).toBeVisible();In a real workflow
The admin’s orders screen has a sortable, paginated table where you change an order’s status inline, and a 500-row archive that loads as you scroll. Sign in, sort by total, edit a status, and find an order deep in the archive.
COR Lens generates locators for shadow DOM, iframes and tables, and grades each one. Click the web tables above with it and compare its pick with yours.
Add to Chrome