{
  "slug": "locator-adds-waitforfunction-0bf0d0baaedf",
  "title": "Locator adds waitForFunction()",
  "tools": [
    "playwright"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-07-24T21:55:03.000Z",
  "announced_at": "2026-07-24T21:55:03.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "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.",
    "examples": [
      "const status = page.getByTestId('status');\nawait status.waitForFunction((element, value) => element.textContent === value, 'Ready');"
    ],
    "gotchas": [
      "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."
    ]
  },
  "why_it_matters": "Wait for a condition on a matching element before continuing a test.",
  "sources": [
    "https://github.com/microsoft/playwright/releases/tag/v1.62.0",
    "https://playwright.dev/docs/api/class-locator#locator-wait-for-function"
  ],
  "rank": 0.96038,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v1+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "backfill-20261007",
    "verdict_id": "backfill-20261007:backfill-20261007-48c92cac04e84aed-8:gate",
    "evidence_hash": "b17276139b84e8e6a01d64416d3a7c27f07ddffc91b7a327300bf595585d287e"
  },
  "review": {
    "draft_hash": "847173885e8db8f57fca4dcefcf8c5a7dadf9d6874d3b0c9fbf6d689812a1985",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "backfill-20261007:gate",
    "reason": "3 of 3 judge runs approved with p_yes >= 0.9 (mean 0.96 >= 0.9; 2 needed) and Jev gave 0.73 (>= 0.6 needed)."
  }
}
