Playwright.AbortController (Playwright v1.65.0-rc.3)

Copy Markdown View Source

The DOM AbortController: aborts the calls given its signal/1 as signal: option.

controller = Playwright.AbortController.new()
signal = Playwright.AbortController.signal(controller)
Task.start(fn -> Process.sleep(1000); Playwright.AbortController.abort(controller) end)
{:error, %Playwright.AbortError{}} = Playwright.Locator.click(button, signal: signal, timeout: 0)

Any process can abort. The calls fail with Playwright.AbortError, whose cause is the reason; matchers fail like a timeout ("The assertion was aborted").

Runtime support (not ported from upstream). A controller is global, as in JS: its signal works with calls on any driver (see Playwright.AbortSignal).

Summary

Types

t()

An abort controller.

Functions

controller.abort(reason): aborts the signal, from any process; its listeners have run when it returns (see Playwright.AbortSignal). Without a reason (nil), the reason is an AbortError "This operation was aborted" (JS: a DOMException of that name). Aborting twice does nothing.

new AbortController().

controller.signal.

Types

t()

@type t() :: %Playwright.AbortController{signal: Playwright.AbortSignal.t()}

An abort controller.

Functions

abort(abort_controller, reason \\ nil)

@spec abort(t(), term()) :: :ok

controller.abort(reason): aborts the signal, from any process; its listeners have run when it returns (see Playwright.AbortSignal). Without a reason (nil), the reason is an AbortError "This operation was aborted" (JS: a DOMException of that name). Aborting twice does nothing.

new()

@spec new() :: t()

new AbortController().

signal(abort_controller)

@spec signal(t()) :: Playwright.AbortSignal.t()

controller.signal.