Fluffy.Locator (Fluffy v0.2.0)

Copy Markdown View Source

A lazy, driver-independent element query.

Role locators accept these options:

  • :name (String.t/0) - Restrict the role locator by accessible name.

  • :exact (boolean/0) - Require an exact, case-sensitive accessible-name match.

Text, label, placeholder, alternative-text, and title locators accept:

  • :exact (boolean/0) - Require an exact, case-sensitive match.

Test-id locators accept:

  • :attribute (String.t/0) - Attribute used as the test-id source. The default value is "data-testid".

filter/2 accepts:

  • :has (struct of type Fluffy.Locator) - Keep elements containing a match for this locator.

  • :has_text (String.t/0) - Keep elements containing this normalized text.

  • :has_not (struct of type Fluffy.Locator) - Keep elements containing no match for this locator.

  • :has_not_text (String.t/0) - Keep elements that do not contain this normalized text.

Summary

Types

exact_option()

@type exact_option() :: {:exact, boolean()}

filter_option()

@type filter_option() ::
  {:has, t()}
  | {:has_text, binary()}
  | {:has_not, t()}
  | {:has_not_text, binary()}

role_option()

@type role_option() :: {:name, binary()} | {:exact, boolean()}

t()

@type t() :: %Fluffy.Locator{operations: [term()]}

test_id_option()

@type test_id_option() :: {:attribute, binary()}

Functions

append(locator, operation)

by_alt_text(text, options \\ [])

@spec by_alt_text(String.t(), [exact_option()]) :: t()

by_alt_text(parent, text, options)

@spec by_alt_text(t(), String.t(), [exact_option()]) :: t()

by_css(css)

by_css(parent, css)

by_label(text, options \\ [])

@spec by_label(String.t(), [exact_option()]) :: t()

by_label(parent, text, options)

@spec by_label(t(), String.t(), [exact_option()]) :: t()

by_placeholder(text, options \\ [])

@spec by_placeholder(String.t(), [exact_option()]) :: t()

by_placeholder(parent, text, options)

@spec by_placeholder(t(), String.t(), [exact_option()]) :: t()

by_role(role, options \\ [])

@spec by_role(atom(), [role_option()]) :: t()
@spec by_role(t(), atom()) :: t()

by_role(parent, role, options)

@spec by_role(t(), atom(), [role_option()]) :: t()

by_test_id(test_id, options \\ [])

@spec by_test_id(String.t(), [test_id_option()]) :: t()

by_test_id(parent, test_id, options)

@spec by_test_id(t(), String.t(), [test_id_option()]) :: t()

by_text(text, options \\ [])

@spec by_text(String.t(), [exact_option()]) :: t()

by_text(parent, text, options)

@spec by_text(t(), String.t(), [exact_option()]) :: t()

by_title(text, options \\ [])

@spec by_title(String.t(), [exact_option()]) :: t()

by_title(parent, text, options)

@spec by_title(t(), String.t(), [exact_option()]) :: t()

describe(locator)

filter(locator, options)

@spec filter(t(), [filter_option()]) :: t()

first(locator)

last(locator)

new(operation)

nth(locator, index)