Wallaby.Element (wallaby v0.27.0) View Source

Defines an Element Struct and interactions with Elements.

Typically these functions are used in conjunction with a find:

page
|> find(Query.css(".some-element"), fn(element) -> Element.click(element) end)

These functions can be used to create new actions specific to your application:

def create_todo(todo_field, todo_text) do
  todo_field
  |> Element.click()
  |> Element.fill_in(with: todo_text)
  |> Element.send_keys([:enter])
end

Retrying

Unlike Browser the actions in Element do not retry if the element becomes stale. Instead an exception will be raised.

Link to this section Summary

Functions

Gets the value of the element's attribute.

Clears any value set in the element.

Clicks the element.

Fills in the element with the specified value.

Hovers on the element.

Returns a boolean based on whether or not the element is selected.

Sends keys to the element.

Sets the value of the element.

Gets the element's text value.

Matches the Element's value with the provided value.

Returns a boolean based on whether or not the element is visible.

Link to this section Types

Specs

attr() :: String.t()

Specs

keys_to_send() :: String.t() | [atom() | String.t()]

Specs

t() :: %Wallaby.Element{
  driver: module(),
  id: String.t(),
  parent: term(),
  screenshots: list(),
  session_url: String.t(),
  url: String.t()
}

Specs

value() :: String.t() | number() | :selected | :unselected

Link to this section Functions

Specs

attr(t(), attr()) :: String.t() | nil

Gets the value of the element's attribute.

Specs

clear(t()) :: t()

Clears any value set in the element.

Link to this function

click(element, retry_count \\ 0)

View Source

Clicks the element.

Specs

fill_in(t(), [{:with, String.t() | number()}]) :: t()

Fills in the element with the specified value.

Specs

hover(t()) :: t()

Hovers on the element.

Specs

selected?(t()) :: boolean()

Returns a boolean based on whether or not the element is selected.

Note

This only really makes sense for options, checkboxes, and radio buttons. Everything else will simply return false because they have no notion of "selected".

Link to this function

send_keys(element, text)

View Source

Specs

send_keys(t(), keys_to_send()) :: t()

Sends keys to the element.

Link to this function

set_value(element, value)

View Source

Specs

set_value(t(), value()) :: t()

Sets the value of the element.

Specs

text(t()) :: String.t()

Gets the element's text value.

If the element is not visible, the return value will be "".

Specs

value(t()) :: String.t()

Matches the Element's value with the provided value.

Specs

visible?(t()) :: boolean()

Returns a boolean based on whether or not the element is visible.