You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: table/grid locators for targeting cells by row/column index or labels聽#40248
There doesn't appear to be an easy way to select a cell in a similar way to how a user would do it. This makes interactive grids and data tables a little bit awkward to work with using getByRole(). Maybe we can expand the options in getByRole()?
New options
Option
Type
Description
rowIndex
number
Targets elements based on row index, either inferred or assigned with aria-rowindex. Applies to table and grid roles.
columnIndex
number
Targets elements based on column index, either inferred or assigned with aria-colindex. Applies to table and grid roles.
rowLabel
string | RegExp | string[] | RegExp[]
Targets elements based on the accessible name(s) of one or more row headers present in the same row. Applies to table and grid roles.
columnLabel
string | RegExp | string[] | RegExp[]
Targets elements based on the accessible name(s) of one or more column headers present in the same row. Applies to table and grid roles.
Example
test("I can change a cell value",({ page })=>{constcell=page.getByRole("table",{name: "My Table"}).getByRole("cell",{rowLabel: "Gross Profit",columnLabel: "April 2026"});expect(cell).toContainText("拢 0");cell.pressSequentially("123")cell.press("Enter");expect(cell).toContainText("拢 123");});
Motivation
It's nice to use accessibility-first locators like getByRole(). They make tests resilient and force developers to build applications with the correct roles and attributes. Having a way to locate a cell in the same way a user would (via the row/column headers or row/column index) would improve E2E tests that target tables and interactive data grids.
I see #33111 is asking for some table helpers, but this request is more focused on extending getByRole() in the same way that other options like selected or pressed work.
Activity
yury-s commentedon Apr 16, 2026
Folding into #4646