Fluffy.Event (Fluffy v0.1.1)

Copy Markdown View Source

Typed event-wait values and event capture orchestration.

Download events accept:

  • :timeout (non_neg_integer/0) - Maximum time in milliseconds to wait for the operation.

  • :max_bytes (non_neg_integer/0) - Maximum number of response bytes to retain; defaults to 10,000,000.

Dialog events accept:

  • :timeout (non_neg_integer/0) - Maximum time in milliseconds to wait for the operation.

  • :decision (:accept, :dismiss, {:accept, prompt_text}, or a one-argument function) - Accept, dismiss, accept with prompt text, or decide from the captured dialog.

  • :accept (true or String.t/0) - Compatibility shorthand for accepting, optionally with prompt text.

  • :dismiss (true) - Compatibility shorthand for dismissing the dialog.

File-chooser, popup, navigation, request, and response events accept the shared timeout option:

  • :timeout (non_neg_integer/0) - Maximum time in milliseconds to wait for the operation.

Summary

Types

dialog_option()

@type dialog_option() ::
  {:timeout, non_neg_integer()}
  | {:decision,
     :accept
     | :dismiss
     | {:accept, String.t()}
     | (Fluffy.Dialog.t() -> :accept | :dismiss | {:accept, String.t()})}
  | {:accept, true | String.t()}
  | {:dismiss, true}

download_option()

@type download_option() ::
  {:timeout, non_neg_integer()} | {:max_bytes, non_neg_integer()}

network_option()

@type network_option() ::
  {:timeout, non_neg_integer()}
  | {:matcher, String.t() | Regex.t() | (term() -> boolean())}

option()

t()

@type t() :: %Fluffy.Event{key: term(), options: keyword(), type: type()}

timeout_option()

@type timeout_option() :: {:timeout, non_neg_integer()}

type()

@type type() ::
  :dialog
  | :download
  | :file_chooser
  | :navigation
  | :page
  | :request
  | :response

Functions

dialog(key, options \\ [])

@spec dialog(term(), [dialog_option()]) :: t()

download(key, options \\ [])

@spec download(term(), [download_option()]) :: t()

file_chooser(key, options \\ [])

@spec file_chooser(term(), [timeout_option()]) :: t()

Captures the browser file chooser opened by the action.

popup(key, options \\ [])

@spec popup(term(), [timeout_option()]) :: t()

Captures a new page opened by the action. Requires Playwright.

request(key, matcher, options \\ [])

@spec request(term(), String.t() | Regex.t() | (term() -> boolean()), [
  timeout_option()
]) :: t()

response(key, matcher, options \\ [])

@spec response(term(), String.t() | Regex.t() | (term() -> boolean()), [
  timeout_option()
]) :: t()