Plushie.Automation.Session (Plushie v0.6.0)

Copy Markdown View Source

An automation client attached to a running Plushie app.

The script layer does not start apps itself. Start the app with Plushie.start_link/2 or a mix task, then attach to the running instance or runtime process and drive it through the real runtime and bridge.

Summary

Functions

Attaches to a running Plushie app.

Moves on a canvas. Options: window: for multi-window apps.

Presses on a canvas. Options: window: for multi-window apps.

Releases on a canvas. Options: window: for multi-window apps.

Clicks a widget. Options: window: for multi-window apps.

Cycles focus in a pane grid. Options: window: for multi-window apps.

Pastes text into a widget. Options: window: for multi-window apps.

Scrolls a scrollable widget. Options: window: for multi-window apps.

Selects a value from a pick list, combo box, or radio group. Options: window: for multi-window apps.

Slides a slider to the given value. Options: window: for multi-window apps.

Sorts a table column. Options: window: for multi-window apps.

Submits a text input. Options: window: for multi-window apps.

Toggles a checkbox or toggler. Options: window: for multi-window apps.

Types text into a text input or editor. Options: window: for multi-window apps.

Types

bridge_ref()

@type bridge_ref() :: GenServer.server() | nil

runtime_ref()

@type runtime_ref() :: GenServer.server()

selector()

@type selector() ::
  String.t()
  | {:text, String.t()}
  | {:role, String.t()}
  | {:label, String.t()}
  | :focused

Automation selector.

String selectors follow these rules:

  • "#save" matches a unique local widget ID
  • "#form/save" matches an exact scoped ID
  • {:text, "Save"} matches visible text content

t()

@type t() :: %Plushie.Automation.Session{bridge: bridge_ref(), runtime: runtime_ref()}

Functions

attach(opts)

@spec attach(opts :: keyword()) :: t()

Attaches to a running Plushie app.

Accepted options:

  • :instance -- Plushie instance name; resolves runtime and bridge automatically
  • :runtime -- runtime pid or registered name
  • :bridge -- bridge pid or registered name

await_async(session, tag, timeout \\ 5000)

@spec await_async(session :: t(), tag :: atom(), timeout :: non_neg_integer()) :: :ok

canvas_move(session, selector, x, y, opts \\ [])

@spec canvas_move(
  session :: t(),
  selector :: selector(),
  x :: number(),
  y :: number(),
  opts :: keyword()
) :: :ok

Moves on a canvas. Options: window: for multi-window apps.

canvas_press(session, selector, x, y, button \\ "left", opts \\ [])

@spec canvas_press(
  session :: t(),
  selector :: selector(),
  x :: number(),
  y :: number(),
  button :: String.t(),
  opts :: keyword()
) :: :ok

Presses on a canvas. Options: window: for multi-window apps.

canvas_release(session, selector, x, y, button \\ "left", opts \\ [])

@spec canvas_release(
  session :: t(),
  selector :: selector(),
  x :: number(),
  y :: number(),
  button :: String.t(),
  opts :: keyword()
) :: :ok

Releases on a canvas. Options: window: for multi-window apps.

click(session, selector, opts \\ [])

@spec click(session :: t(), selector :: selector(), opts :: keyword()) :: :ok

Clicks a widget. Options: window: for multi-window apps.

find(session, selector)

@spec find(session :: t(), selector :: selector()) ::
  Plushie.Automation.Element.t() | nil

find!(session, selector)

@spec find!(session :: t(), selector :: selector()) :: Plushie.Automation.Element.t()

get_diagnostics(session)

@spec get_diagnostics(session :: t()) :: [Plushie.Event.SystemEvent.t()]

model(session)

@spec model(session :: t()) :: term()

move_to(session, x, y)

@spec move_to(session :: t(), x :: number(), y :: number()) :: :ok

pane_focus_cycle(session, selector, opts \\ [])

@spec pane_focus_cycle(session :: t(), selector :: selector(), opts :: keyword()) ::
  :ok

Cycles focus in a pane grid. Options: window: for multi-window apps.

paste(session, selector, text, opts \\ [])

@spec paste(
  session :: t(),
  selector :: selector(),
  text :: String.t(),
  opts :: keyword()
) :: :ok

Pastes text into a widget. Options: window: for multi-window apps.

press(session, key)

@spec press(session :: t(), key :: String.t()) :: :ok

register_effect_stub(session, kind, response)

@spec register_effect_stub(
  session :: t(),
  kind :: Plushie.Effect.kind(),
  response :: term()
) :: :ok

release(session, key)

@spec release(session :: t(), key :: String.t()) :: :ok

screenshot(session, name, opts \\ [])

@spec screenshot(session :: t(), name :: String.t(), opts :: keyword()) ::
  Plushie.Automation.Screenshot.t()

scroll(session, selector, delta_x \\ 0, delta_y \\ 0, opts \\ [])

@spec scroll(
  session :: t(),
  selector :: selector(),
  delta_x :: number(),
  delta_y :: number(),
  opts :: keyword()
) :: :ok

Scrolls a scrollable widget. Options: window: for multi-window apps.

select(session, selector, value, opts \\ [])

@spec select(
  session :: t(),
  selector :: selector(),
  value :: term(),
  opts :: keyword()
) :: :ok

Selects a value from a pick list, combo box, or radio group. Options: window: for multi-window apps.

slide(session, selector, value, opts \\ [])

@spec slide(
  session :: t(),
  selector :: selector(),
  value :: number(),
  opts :: keyword()
) :: :ok

Slides a slider to the given value. Options: window: for multi-window apps.

sort(session, selector, column, direction \\ "asc", opts \\ [])

@spec sort(
  session :: t(),
  selector :: selector(),
  column :: String.t(),
  direction :: String.t(),
  opts :: keyword()
) :: :ok

Sorts a table column. Options: window: for multi-window apps.

submit(session, selector, opts \\ [])

@spec submit(session :: t(), selector :: selector(), opts :: keyword()) :: :ok

Submits a text input. Options: window: for multi-window apps.

toggle(session, selector, value \\ nil, opts \\ [])

@spec toggle(
  session :: t(),
  selector :: selector(),
  value :: boolean() | nil,
  opts :: keyword()
) :: :ok

Toggles a checkbox or toggler. Options: window: for multi-window apps.

tree(session)

@spec tree(session :: t()) :: map()

type_key(session, key)

@spec type_key(session :: t(), key :: String.t()) :: :ok

type_text(session, selector, text, opts \\ [])

@spec type_text(
  session :: t(),
  selector :: selector(),
  text :: String.t(),
  opts :: keyword()
) :: :ok

Types text into a text input or editor. Options: window: for multi-window apps.

unregister_effect_stub(session, kind)

@spec unregister_effect_stub(session :: t(), kind :: Plushie.Effect.kind()) :: :ok