Skip to content

SmartRow

A SmartRow is a Playwright Locator extended with table-aware methods. Every method that returns a row (getRow, findRow, iteration callbacks, etc.) returns a SmartRow.

Because SmartRow extends Locator, all standard Playwright locator methods — click(), innerText(), waitFor(), locator(), etc. — are available directly on the row.

API: Table Methods


Properties

rowIndex

Signature

typescript
rowIndex?: number

The 0-based row index within the table, if known. Set by findRow, findRows, getRowByIndex, filter, and async iteration. May be undefined when returned by getRow.

typescript
const row = await table.findRow({ Name: 'John' });
console.log(row.rowIndex); // e.g. 12

tablePageIndex

Signature

typescript
tablePageIndex?: number

The 0-based page index this row was found on during pagination. Set alongside rowIndex by async operations.


table

Signature

typescript
table: TableResult<T>

Reference back to the parent TableResult. Useful when passing rows between helpers.


Methods

getCell

Signature

typescript
getCell(columnName: string): Locator

Parameters

  • column - Column name (case-sensitive)

Returns a SmartCell (Locator + bringIntoView) for the named column. Column name is case-sensitive.

typescript
const emailCell = row.getCell('Email');
await expect(emailCell).toHaveText('john@example.com');

// SmartCell also exposes bringIntoView
await row.getCell('Notes').bringIntoView();

Guide: Read Cells


toJSON

Signature

typescript
toJSON(options?: { columns?: string[] }): Promise<T>

Parameters

  • options - Optional configuration

Reads all (or specified) columns and returns a plain object.

typescript
const data = await row.toJSON();
// { Name: 'John', Email: 'john@example.com', Status: 'Active' }

const partial = await row.toJSON({ columns: ['Name', 'Status'] });
// { Name: 'John', Status: 'Active' }

Guide: Read Cells


bringIntoView

Signature

typescript
bringIntoView(): Promise<void>

Scrolls and/or paginates to make this row visible. Requires rowIndex to be set — works when the row was returned by findRow, findRows, getRowByIndex, filter, or async iteration.

typescript
const rows = await table.findRows({ Status: 'Flagged' });
for (const row of rows) {
  await row.bringIntoView();
  await expect(row.getCell('Status')).toBeVisible();
}

WARNING

Throws if rowIndex is unknown (e.g., rows from getRow).


smartFill

Signature

typescript
smartFill(
  data: Partial<T>,
  options?: FillOptions
): Promise<void>

Parameters

  • data - Column-value pairs to fill
  • options - Optional configuration

Fills form fields in the row. Auto-detects input type (text, select, checkbox, contenteditable). Uses columnOverrides.write when configured.

typescript
await row.smartFill({ Name: 'Jane', Status: 'Active', Subscribe: true });

// Custom input mapper for a non-standard input
await row.smartFill(
  { Notes: 'Updated' },
  { inputMappers: { Notes: (cell) => cell.locator('.rich-text-editor') } }
);

Guide: Fill Cells


wasFound

Signature

typescript
wasFound(): boolean

Returns false if this is a sentinel "not found" row (e.g., when findRow finds no match in a non-throwing mode). Returns true for any real row.

typescript
const row = await table.findRow({ Name: 'Ghost' });
if (!row.wasFound()) {
  console.log('Row not found');
}