Config Options
All options passed to useTable(locator, config). Every option is optional unless noted.
import { useTable } from '@rickcedwhat/playwright-smart-table';
const table = await useTable(page.locator('#my-table'), {
rowSelector: 'tbody tr',
maxPages: 20,
strategies: { ... },
}).init();→ API: Table Methods · API: Strategies
Selectors
headerSelector
Signature
headerSelector?: SelectorSelector for the column header elements. Accepts a CSS string or a function returning a Locator.
// CSS string
headerSelector: 'thead th'
// Locator function
headerSelector: (root) => root.locator('[role="columnheader"]')rowSelector
Signature
rowSelector?: SelectorCSS selector for the table rows. Scoped to the table locator.
rowSelector: 'tbody tr'
rowSelector: '[role="row"].data-row'cellSelector
Signature
cellSelector?: SelectorSelector for cells within a row. Accepts a CSS string or a function returning a Locator.
// CSS string
cellSelector: 'td'
// Locator function
cellSelector: (row) => row.locator('[role="gridcell"]')Behavior
maxPages
Signature
maxPages?: numberMaximum number of pages to scan during iteration and search operations. Prevents runaway pagination on unexpectedly large tables.
maxPages: 50concurrency
Signature
concurrency?: RowIterationModeDefault concurrency mode for forEach, map, and filter. Can be overridden per-call.
'sequential'— one row at a time, in order. Default forforEachandfilter.'parallel'— all rows on the current page run concurrently. Default formap.'synchronized'— rows run in parallel but page navigation waits for all callbacks to finish.
concurrency: 'sequential'autoScroll
Signature
autoScroll?: booleanWhen true, PST scrolls the table locator into view during init(). Useful when tables render below the fold.
autoScroll: trueHooks
headerTransformer
Signature
headerTransformer?: (args: {
text: string,
index: number,
locator: Locator
}) => string | Promise<string>Rename or normalize column headers at init time. Runs once per header cell during init().
headerTransformer: ({ text, index }) => text.trim() || `Column ${index}`// Rename a known system column
headerTransformer: ({ text }) =>
text.includes('__checkbox__') ? 'Select' : text.trim()onReset
Signature
onReset?: (context: TableContext) => Promise<void>Called after table.reset(). Use to navigate back to the first page, clear filters, or perform any teardown the table requires.
onReset: async ({ root, page }) => {
await page.locator('.pagination-first').click();
}Advanced
columnOverrides
Signature
columnOverrides?: Partial<Record<keyof T, ColumnOverride<T[keyof T]>>>Per-column read and write overrides. Use read to customize how cell text is extracted; use write to customize how values are filled.
columnOverrides: {
Status: {
read: async (cell) => cell.locator('.badge').innerText(),
write: async ({ cell, targetValue }) => {
await cell.locator('select').selectOption(targetValue);
},
},
}→ Guide: Column Overrides · Guide: Fill Cells
debug
Signature
debug?: boolean | DebugConfigEnable verbose logging for development. Pass true for default verbosity or a config object for fine-grained control.
debug: true
debug: { logLevel: 'verbose' }strategies
Signature
strategies?: Partial<TableStrategies>All pluggable strategy overrides — pagination, loading detection, header discovery, sorting, viewport navigation, and more.
strategies: {
pagination: PaginationStrategies.infiniteScroll({ ... }),
loading: { isCellLoading: async (cell) => ... },
}