@rickcedwhat/playwright-smart-table
v6.12.0
Published
Smart, column-aware table interactions for Playwright
Downloads
79,005
Maintainers
Readme
Playwright Smart Table
Production-ready table testing for Playwright with smart column-aware locators.
📚 Full Documentation →
The Problem
Testing HTML tables in Playwright is fragile by default:
// ❌ Breaks if columns reorder
const email = await page.locator('tbody tr').nth(2).locator('td').nth(3).textContent();
// ❌ Manual column mapping every time
const headers = await page.locator('thead th').allTextContents();
const emailIndex = headers.indexOf('Email');
const email = await row.locator('td').nth(emailIndex).textContent();The Solution
// ✅ Column-aware — survives column reordering
const row = table.getRow({ Name: 'John Doe' });
const email = await row.getCell('Email').textContent();
// ✅ Search across pages
const allEngineers = await table.findRows({ Department: 'Engineering' }, { maxPages: 5 });
// ✅ Iterate with forEach, map, filter, or for await...of
await table.forEach(async ({ row }) => {
await row.getCell('Checkbox').click();
});Installation
npm install @rickcedwhat/playwright-smart-tableQuick Start
import { useTable } from '@rickcedwhat/playwright-smart-table';
const table = await useTable(page.locator('#my-table')).init();
const row = table.getRow({ Name: 'John Doe' });
const email = await row.getCell('Email').innerText();Key Features
- 🎯 Column-aware locators — find rows and cells by name, not index
- 📄 Pagination-aware search —
findRowsandforEachscan across pages automatically - 🔁 Iteration methods —
forEach,map,filter, andfor await...of - 🛠️ Debug mode — slow motion playback and structured logs
- 🔌 Extensible strategies — plug in any table implementation or pagination shape
- 💪 Full TypeScript support
MIT © Cedrick Catalan
