sincecutoff.com
← all changes

Locator adds waitForFunction()

Introduced 2026-07-24 · score 0.96

HOW TO USE IT

When a matching element must satisfy a custom condition, call `locator.waitForFunction()` with a page-context function; it waits until the function returns a truthy value.

const status = page.getByTestId('status'); await status.waitForFunction((element, value) => element.textContent === value, 'Ready');

WHY THIS HELPS

Wait for a condition on a matching element before continuing a test.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.62.0
  • pageFunction (required): Function evaluated in the page context; receives the matching element first and the optional `arg` second. Waiting ends when its result is truthy.
  • arg: Optional argument passed to `pageFunction`.
  • options.timeout: Maximum wait in milliseconds; defaults to 0 (no timeout).
  • Prerequisite: `locator.waitForFunction()` was added in Playwright v1.62.
  • The function is called with the matching element and must return a truthy value for the wait to finish.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card