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
Something like accessing the rows by index and the columns by index or header value would be nice I think. Had that use case in one of my past projects.
Reacted by Matt Duffield, rough, mekxtari, Alexander Eneroth, Kevin Howard, riawiththesam, Jessica Christin Piontke and Maximilian Teegen
I think table selector will be very useful. Tables are used a lot in CRM screens. I think it will be especially useful if we can select based on table data and column name rather than row/column number.
I will try to explain it using example of the table here: https://www.seleniumeasy.com/test/table-search-filter-demo.html
I can find a cell using row and column number. playwright.$(':nth-match(tr,5) >> :nth-match(td,3)') returns <td>Emily John</td>
I also can take a row using text: playwright.$('tr:has-text("Bootstrap 3") >> :nth-match(td,3)') It works in this example but may not work if the other row has the same text in the other column.
It would be great to be able to find a cell by saying: bring me the value of column Assignee where the text of column Task="Bootstrap 3". It is similar what SQL does.
where you represent the table as an array. Since this was part of simply writing an assertion for a specific scenario, it does not concern itself with all the intricacies of tables (e.g. multi-spanning cells, partially matching some rows, etc.).
This is a very common use case of mine. I ended up creating a custom selector for it but I also think playwright should support this natively.
For instance, I have a custom selector by-header-cell that retrieves all data cells that correspond to a given header cell. I can then intercept cells by row and column:
Activity
roughsoft commentedon Dec 9, 2020
table selector engineer.
buhichan commentedon Dec 22, 2020
+1, really need this to make useful test scripts.
mxschmitt commentedon Dec 22, 2020
Something like accessing the rows by index and the columns by index or header value would be nice I think. Had that use case in one of my past projects.
ygsf commentedon Jun 7, 2021
I think table selector will be very useful. Tables are used a lot in CRM screens. I think it will be especially useful if we can select based on table data and column name rather than row/column number.
I will try to explain it using example of the table here: https://www.seleniumeasy.com/test/table-search-filter-demo.html
I can find a cell using row and column number.
playwright.$(':nth-match(tr,5) >> :nth-match(td,3)')returns<td>Emily John</td>I also can take a row using text:
playwright.$('tr:has-text("Bootstrap 3") >> :nth-match(td,3)')It works in this example but may not work if the other row has the same text in the other column.It would be great to be able to find a cell by saying: bring me the value of column
Assigneewhere the text of columnTask="Bootstrap 3". It is similar what SQL does.rwoll commentedon Jun 10, 2022
https://github.com/microsoft/playwright/pull/14763/files#diff-2d78fbd6a992ff94180cd23823c6d2554508544536c13cdfaa696de2f9f998a6R157 coincidentally implemented a naïve table selector where the API looks like:
where you represent the table as an array. Since this was part of simply writing an assertion for a specific scenario, it does not concern itself with all the intricacies of tables (e.g. multi-spanning cells, partially matching some rows, etc.).
ruifigueira commentedon Nov 13, 2024
This is a very common use case of mine. I ended up creating a custom selector for it but I also think playwright should support this natively.
For instance, I have a custom selector
by-header-cellthat retrieves all data cells that correspond to a given header cell. I can then intercept cells by row and column:Some references regarding data cells / header cells relationship:
qwertysk commentedon Nov 20, 2024
Rui Figueira (@ruifigueira) very interesting, pls can you share your code with custom selector ?
ruifigueira commentedon Nov 20, 2024
Sure, here's a basic selector and example test:
NOTE:
This, as I said, is a basic selector, and doesn't handle more advanced cases like
colspan,rowspan, multiple column/row headers, etc.vethman commentedon Jun 2, 2025
I have made the following package which really helps me testing HTML-tables. Have a look please:
https://www.npmjs.com/package/@cerios/playwright-table
andyearnshaw commentedon Apr 17, 2026
Here's my suggestion, originally posted in #40248.
New
getByRole()optionsrowIndexaria-rowindex. Applies totableandgridroles.columnIndexaria-colindex. Applies totableandgridroles.rowLabeltableandgridroles.columnLabeltableandgridroles.Example