Skip to content

waygraph / sel

Variable: sel ​

const sel: object

Defined in: src/engine/trait/selector.ts:35

Type Declaration ​

altText ​

altText: (value, options?) => string

By an image's alternative text (getByAltText).

Parameters ​

value ​

string | RegExp

options? ​
exact? ​

boolean

Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace.

Returns ​

string

Example ​

ts
sel.altText("Company logo")

label ​

label: (value, options?) => string

By the text of the label a form control has (getByLabel).

Parameters ​

value ​

string | RegExp

options? ​
exact? ​

boolean

Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace.

Returns ​

string

Example ​

ts
sel.label("Email")

placeholder ​

placeholder: (value, options?) => string

By a field's placeholder (getByPlaceholder).

Parameters ​

value ​

string | RegExp

options? ​
exact? ​

boolean

Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace.

Returns ​

string

Example ​

ts
sel.placeholder("Search")

text ​

text: (value, options?) => string

By visible text (getByText): a substring, ignoring case, unless { exact: true }.

Parameters ​

value ​

string | RegExp

options? ​
exact? ​

boolean

Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace.

Returns ​

string

Example ​

ts
sel.text("Sign in")

title ​

title: (value, options?) => string

By the title attribute (getByTitle).

Parameters ​

value ​

string | RegExp

options? ​
exact? ​

boolean

Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace.

Returns ​

string

Example ​

ts
sel.title("Close")

css() ​

css(raw): string

A plain CSS selector: an id, a class, a tag, an attribute, or any mix of them. Throws at once on an XPath or a regex text match, the things plain CSS is meant to steer away from (a raw string is still fine when the DOM has nothing stable).

Parameters ​

raw ​

string

Returns ​

string

Example ​

ts
sel.css("#login-button")

role() ​

role(role, options?): string

By ARIA role and accessible name, with getByRole's own options (name, exact, checked, disabled, selected, expanded, pressed, level, includeHidden): the role is the union of roles, so a typo is a compile error.

Parameters ​

role ​

"alert" | "document" | "menubar" | "status" | "toolbar" | "none" | "search" | "link" | "dialog" | "option" | "list" | "table" | "article" | "blockquote" | "button" | "caption" | "code" | "figure" | "form" | "img" | "main" | "menu" | "meter" | "strong" | "time" | "switch" | "math" | "marquee" | "menuitem" | "banner" | "heading" | "scrollbar" | "alertdialog" | "application" | "cell" | "checkbox" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "deletion" | "directory" | "emphasis" | "feed" | "generic" | "grid" | "gridcell" | "group" | "insertion" | "listbox" | "listitem" | "log" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "note" | "paragraph" | "presentation" | "progressbar" | "radio" | "radiogroup" | "region" | "row" | "rowgroup" | "rowheader" | "searchbox" | "separator" | "slider" | "spinbutton" | "subscript" | "superscript" | "tab" | "tablist" | "tabpanel" | "term" | "textbox" | "timer" | "tooltip" | "tree" | "treegrid" | "treeitem"

options? ​

{ checked?: boolean; description?: string | RegExp; disabled?: boolean; exact?: boolean; expanded?: boolean; includeHidden?: boolean; level?: number; name?: string | RegExp; pressed?: boolean; selected?: boolean; } | undefined = {}

Type Literal ​

{ checked?: boolean; description?: string | RegExp; disabled?: boolean; exact?: boolean; expanded?: boolean; includeHidden?: boolean; level?: number; name?: string | RegExp; pressed?: boolean; selected?: boolean; }

checked? ​

boolean

An attribute that is usually set by aria-checked or native <input type=checkbox> controls.

Learn more about aria-checked.

description? ​

string | RegExp

Option to match the accessible description. By default, matching is case-insensitive and searches for a substring, use exact to control this behavior.

Learn more about accessible description.

disabled? ​

boolean

An attribute that is usually set by aria-disabled or disabled.

NOTE Unlike most other attributes, disabled is inherited through the DOM hierarchy. Learn more about aria-disabled.

exact? ​

boolean

Whether name and description are matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when the value is a regular expression. Note that exact match still trims whitespace.

expanded? ​

boolean

An attribute that is usually set by aria-expanded.

Learn more about aria-expanded.

includeHidden? ​

boolean

Option that controls whether hidden elements are matched. By default, only non-hidden elements, as defined by ARIA, are matched by role selector.

Learn more about aria-hidden.

level? ​

number

A number attribute that is usually present for roles heading, listitem, row, treeitem, with default values for <h1>-<h6> elements.

Learn more about aria-level.

name? ​

string | RegExp

Option to match the accessible name. By default, matching is case-insensitive and searches for a substring, use exact to control this behavior.

Learn more about accessible name.

pressed? ​

boolean

An attribute that is usually set by aria-pressed.

Learn more about aria-pressed.

selected? ​

boolean

An attribute that is usually set by aria-selected.

Learn more about aria-selected.


undefined

Returns ​

string

Example ​

ts
sel.role("button", { name: "Login" }) · sel.role("checkbox", { name: "Remember me", checked: true })

testId() ​

testId(id, options?): string

By test id. The attribute is data-testid; pass { attribute } for the one the app uses (data-test, data-qa).

Parameters ​

id ​

string | RegExp

options? ​
attribute? ​

string

Returns ​

string

Example ​

ts
sel.testId("username") · sel.testId("username", { attribute: "data-test" })

within() ​

within(parent, child): string

One selector inside another: child among the descendants of parent.

Parameters ​

parent ​

string

child ​

string

Returns ​

string

Example ​

ts
sel.within(sel.css("form#login"), sel.role("button", { name: "Login" }))

waygraph 0.18.3 (alpha) · Node 24+ · peer @playwright/test ^1.40.0 · syntax may change before 1.0: see what was removed