wallaby v0.17.0 Wallaby.Element

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.

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

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

Types

attr()
attr() :: String.t
keys_to_send()
keys_to_send() :: String.t | [atom | String.t]
t()
t() :: %Wallaby.Element{driver: module, id: String.t, parent: term, screenshots: list, session_url: String.t, url: String.t}
value()

Functions

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

Gets the value of the element’s attribute.

clear(element)
clear(t) :: t

Clears any value set in the element.

click(element)
click(t) :: t

Clicks the element.

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

Fills in the element with the specified value.

selected?(element)
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”.

send_keys(element, text)
send_keys(t, keys_to_send) :: t

Sends keys to the element.

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

Sets the value of the element.

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

Returns the text from the element.

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

Matches the Element’s value with the provided value.

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

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