wallaby v0.19.1 Wallaby.Element 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

Fills in the element with the specified value

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

Sends keys to the element

Sets the value of the element

Returns the text from the element

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

Link to this type keys_to_send() View Source
keys_to_send() :: String.t | [atom | String.t]
Link to this type t() View Source
t() :: %Wallaby.Element{driver: module, id: String.t, parent: term, screenshots: list, session_url: String.t, url: String.t}
Link to this type value() View Source
value() :: String.t | number | :selected | :unselected

Link to this section Functions

Link to this function attr(element, name) View Source
attr(t, attr) :: String.t | nil

Gets the value of the element’s attribute.

Link to this function clear(element) View Source
clear(t) :: t

Clears any value set in the element.

Link to this function click(element, retry_count \\ 0) View Source

Clicks the element.

Link to this function fill_in(element, list) View Source
fill_in(t, [{:with, String.t | number}]) :: t

Fills in the element with the specified value.

Link to this function selected?(element) View Source
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
send_keys(t, keys_to_send) :: t

Sends keys to the element.

Link to this function set_value(element, value) View Source
set_value(t, value) :: t

Sets the value of the element.

Returns the text from the element.

Matches the Element’s value with the provided value.

Link to this function visible?(element) View Source
visible?(t) :: boolean

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