Playwright operations and assertions accept AbortSignal
Introduced 2026-07-24 · score 0.98
HOW TO USE IT
When a browser action or web-first assertion needs to be cancellable, pass an `AbortSignal` in its `signal` option. To disable the operation’s default timeout too, pass `timeout: 0`.
const controller = new AbortController();
setTimeout(() => controller.abort(), 1000);
await page.getByRole('button', { name: 'Submit' }).click({ signal: controller.signal });
await expect(page.getByText('Done')).toBeVisible({ signal: controller.signal });await page.getByRole('button', { name: 'Submit' }).click({ signal: controller.signal, timeout: 0 });WHY THIS HELPS
Cancel a long-running browser action or assertion during a test.
REQUIREMENTS AND LIMITATIONS
- Version: v1.62.0
- signal: An `AbortSignal` that cancels the operation; for locator assertions, aborting fails the assertion like a timeout.
- timeout: Maximum time in milliseconds. For operations, `0` disables the timeout; assertion timeout defaults to `TestConfig.expect`.
- Prerequisite: The `signal` option was added in Playwright v1.62.
- Most operations and web-first assertions accept `signal`.
- Providing a signal does not disable the default timeout; pass `timeout: 0` to disable it.
FIRST-PARTY EVIDENCE
- https://github.com/microsoft/playwright/releases/tag/v1.62.0
- https://playwright.dev/docs/api/class-locator
- https://playwright.dev/docs/next/api/class-locatorassertions
Check the installed version and the source before using it. Entry JSON