Pages.Driver behaviour (Pages v4.1.0)

View Source

Defines types and behaviours that page drivers must implement.

Summary

Callbacks

Click an element within a page. Implementation for Pages.click/4.

Wait for a server-issued redirect. Implementation for Pages.handle_redirect/1.

Attempt to open the current page in a web browser.

Render a change. Implementation for Pages.render_change/3.

Render a hook event. Implementation for Pages.render_hook/3.

Re-renders the page. Implementation for Pages.rerender/1.

Submit a form targeted by the given selector. Implementation for Pages.submit_form/2.

Submit a form targeted by the given selector. Implementation for Pages.submit_form/3.

Fills in a form with the attributes and submits it. Implementation for Pages.submit_form/5.

Fills in a form with the attributes without submitting it. Implementation for Pages.update_form/4.

Fills in a form with the attributes without submitting it. Implementation for Pages.update_form/5.

Navigate directly to a page. Implementation for Pages.visit/2.

Target a child component for actions. Implementation for Pages.with_child_component/3.

Types

Callbacks

click(t, http_method, arg3, selector)

(optional)
@callback click(
  t(),
  Pages.http_method(),
  Pages.text_filter() | nil,
  HtmlQuery.Css.selector()
) ::
  Pages.result() | no_return()

Click an element within a page. Implementation for Pages.click/4.

handle_redirect(t, keyword)

(optional)
@callback handle_redirect(
  t(),
  keyword()
) :: Pages.result()

Wait for a server-issued redirect. Implementation for Pages.handle_redirect/1.

open_browser(t)

@callback open_browser(t()) :: t()

Attempt to open the current page in a web browser.

render_change(t, selector, t)

(optional)
@callback render_change(t(), HtmlQuery.Css.selector(), Enum.t()) :: Pages.result()

Render a change. Implementation for Pages.render_change/3.

render_hook(t, binary, attrs_t, keyword)

(optional)
@callback render_hook(t(), binary(), Pages.attrs_t(), keyword()) :: Pages.result()

Render a hook event. Implementation for Pages.render_hook/3.

render_upload(t, live_view_upload, binary, integer)

(optional)
@callback render_upload(t(), Pages.live_view_upload(), binary(), integer()) ::
  Pages.result()

Render a file upload. Implementation for Pages.render_upload/4.

rerender(t)

(optional)
@callback rerender(t()) :: Pages.result()

Re-renders the page. Implementation for Pages.rerender/1.

submit_form(t, selector)

(optional)
@callback submit_form(t(), HtmlQuery.Css.selector()) :: Pages.result()

Submit a form targeted by the given selector. Implementation for Pages.submit_form/2.

submit_form(t, selector, attrs, hidden_attrs)

(optional)
@callback submit_form(
  t(),
  HtmlQuery.Css.selector(),
  attrs :: Pages.attrs_t(),
  hidden_attrs :: Pages.attrs_t()
) :: Pages.result()

Submit a form targeted by the given selector. Implementation for Pages.submit_form/3.

submit_form(t, selector, schema, attrs, hidden_attrs)

(optional)
@callback submit_form(
  t(),
  HtmlQuery.Css.selector(),
  schema :: atom(),
  attrs :: Pages.attrs_t(),
  hidden_attrs :: Pages.attrs_t()
) :: Pages.result()

Fills in a form with the attributes and submits it. Implementation for Pages.submit_form/5.

update_form(t, selector, attrs, opts)

(optional)
@callback update_form(
  t(),
  HtmlQuery.Css.selector(),
  attrs :: Pages.attrs_t(),
  opts :: Keyword.t()
) :: Pages.result()

Fills in a form with the attributes without submitting it. Implementation for Pages.update_form/4.

When interactive with forms backed by multiple changesets, or forms not backed by any changesets, one may choose to pass custon nested maps or keywords matching the structure of the params to be received in a controller or live view.

update_form(t, selector, schema, attrs, opts)

(optional)
@callback update_form(
  t(),
  HtmlQuery.Css.selector(),
  schema :: atom(),
  attrs :: Pages.attrs_t(),
  opts :: Keyword.t()
) :: Pages.result()

Fills in a form with the attributes without submitting it. Implementation for Pages.update_form/5.

When updating a form built using Phoenix.Component.to_form/2 with the :as option, one may use the name prefix of the form as the :schema atom.

visit(t, t)

@callback visit(t(), Path.t()) :: Pages.result()

Navigate directly to a page. Implementation for Pages.visit/2.

with_child_component(t, child_id, function)

(optional)
@callback with_child_component(t(), child_id :: binary(), (t() -> term())) :: t()

Target a child component for actions. Implementation for Pages.with_child_component/3.