gleewright/locator
Locators find elements on a page. They are lazy: creating a locator doesn’t touch the page, and every action re-resolves it, waiting for the element to be attached, visible, stable and enabled as needed.
Create locators from a page with page.get_by_role, page.get_by_text,
… and narrow them down with the functions in this module.
Types
A way to find elements on a page. Create one with the get_by_*
functions in gleewright/page.
pub type Locator
Values
pub fn all_inner_texts(
locator: Locator,
) -> step.Step(List(String))
The rendered text of every matching element.
pub fn attribute(
locator: Locator,
name: String,
) -> step.Step(option.Option(String))
The value of an attribute of the element.
pub fn containing(locator: Locator, inner: Locator) -> Locator
Keep only elements that contain an element matching inner. inner is
resolved relative to each element, so create it from the page.
pub fn describe(locator: Locator) -> String
A description of the locator, e.g. getByRole('button').
pub fn fill(locator: Locator, text: String) -> step.Step(Nil)
Replace the value of an input or textarea with the given text.
pub fn get_by_exact_text(scope: Locator, text: String) -> Locator
Find elements whose text is exactly the given text.
pub fn get_by_label(scope: Locator, text: String) -> Locator
Find form controls by the text of their <label> or aria-label.
pub fn get_by_placeholder(
scope: Locator,
text: String,
) -> Locator
Find inputs by their placeholder text.
pub fn get_by_role(scope: Locator, role: role.Role) -> Locator
Find elements with the given ARIA role inside this locator.
pub fn get_by_role_exactly_named(
scope: Locator,
role: role.Role,
name: String,
) -> Locator
Like get_by_role_named, but the accessible name must match exactly. An
empty name matches only elements with no accessible name.
pub fn get_by_role_named(
scope: Locator,
role: role.Role,
name: String,
) -> Locator
Find elements with the given ARIA role and accessible name inside this locator. The name matches case-insensitively as a substring.
pub fn get_by_test_id(scope: Locator, id: String) -> Locator
Find elements by their data-testid attribute.
pub fn get_by_text(scope: Locator, text: String) -> Locator
Find elements containing the given text (case-insensitive substring).
pub fn get_by_title(scope: Locator, text: String) -> Locator
Find elements by their title attribute.
pub fn input_value(locator: Locator) -> step.Step(String)
The current value of an input, textarea or select.
pub fn is_checked(locator: Locator) -> step.Step(Bool)
Whether the checkbox or radio button is currently checked.
pub fn locator(scope: Locator, selector: String) -> Locator
Find elements matching a CSS or XPath selector inside this locator.
pub fn nth(locator: Locator, index: Int) -> Locator
The matching element at the given zero-based index.
pub fn press(locator: Locator, key: String) -> step.Step(Nil)
Focus the element and press a key or key combination, e.g. "Enter" or
"Control+a".
pub fn select_option(
locator: Locator,
value: String,
) -> step.Step(Nil)
Select an option in a <select> by its value or label.
pub fn set_input_file(
locator: Locator,
path: String,
) -> step.Step(Nil)
Set the file of an <input type="file">.
pub fn text_content(
locator: Locator,
) -> step.Step(option.Option(String))
The textContent of the element.
pub fn type_text(
locator: Locator,
text: String,
) -> step.Step(Nil)
Type text into the element one key at a time, firing keyboard events for
each character. Prefer fill unless the page reacts to individual keys.
pub fn wait_for(locator: Locator, state: State) -> step.Step(Nil)
Wait until the element reaches the given state.
pub fn with_text(locator: Locator, text: String) -> Locator
Keep only elements that contain the given text somewhere inside them.