← Back to library
Playwrightassertionsbeginnerv1.20+
Assert table row count
Count rows in an HTML table and assert the exact number.
1test('table renders the correct number of rows', async ({ page }) => {
2 await page.goto('/users');
3
4 const rows = page.locator('table tbody tr');
5
6 // Playwright retries the assertion until the count matches
7 await expect(rows).toHaveCount(10);
8
9 // Or assert a minimum
10 const count = await rows.count();
11 expect(count).toBeGreaterThanOrEqual(5);
12});#table#rows#count#toHaveCount