Search documentation of Plushie

# Plushie.Automation.Session (Plushie v0.7.2)

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

### Types

bridge_ref()
runtime_ref()
selector()

Automation selector.

t()

### Functions

attach(opts)

Attaches to a running Plushie app.

await_async(session, tag, timeout \\ 5000)
canvas_move(session, selector, x, y, opts \\ [])

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

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

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

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

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

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

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

find(session, selector, opts \\ [])
find!(session, selector, opts \\ [])
model(session)
move_to(session, x, y)
pane_focus_cycle(session, selector, opts \\ [])

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

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

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

press(session, key)
register_effect_stub(session, kind, response)
release(session, key)
screenshot(session, name, opts \\ [])
scroll(session, selector, delta_x \\ 0, delta_y \\ 0, opts \\ [])

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

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

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

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

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

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

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

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

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

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

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

tree(session)
type_key(session, key)
type_text(session, selector, text, opts \\ [])

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

unregister_effect_stub(session, kind)

## 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.

Valid forms:

- `"#save"` matches a unique local widget ID
- `"#form/save"` matches an exact scoped ID
- `{:text, "Save"}` matches visible text (content, label, value, placeholder)
- `{:role, "button"}` matches an accessibility role
- `{:label, "Save"}` matches an accessibility label
- `:focused` matches the currently focused element

Bare strings without a `#` prefix are not valid selectors. Use `{:text, "Save"}` to match by 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, opts \\ [])

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

# find!(session, selector, opts \\ [])

    @spec find!(session :: t(), selector :: selector(), opts :: keyword()) ::
      Plushie.Automation.Element.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