PhxDemo.Target (phx_demo v0.1.1)

Copy Markdown View Source

Turns demo targets into Playwright selectors.

  • "#post_title": any CSS or Playwright selector string, used as-is
  • {:link, "New Post"}: a link with that accessible name
  • {:button, "Save"}: a button with that accessible name
  • {:label, "Title"}: the form control for that label
  • {:text, "Hello"}: an element containing that text
  • {:role, "heading", "Posts"}: any ARIA role and name

Name matching is case-insensitive and substring-based (Playwright's default) unless you pass exact: true as a third element, e.g. {:link, "Post", exact: true}.

Summary

Types

t()

@type t() ::
  String.t()
  | {:link | :button | :label | :text, String.t()}
  | {:link | :button | :label | :text, String.t(), keyword()}
  | {:role, String.t(), String.t()}

Functions

to_selector(selector)

@spec to_selector(t()) :: String.t()