wallaby v0.3.0 Wallaby.Node

Common functionality for interacting with DOM nodes.

Nodes can be found by executing css queries against a page:

visit("/page.html")
|> find("#main-page .dashboard")

Finders can also be chained together to provide scoping:

visit("/page.html")
|> find(".users")
|> find(".user", count: 3)
|> List.first
|> find(".user-name")
|> text

Summary

Functions

Finds all of the DOM nodes that match the css selector. If no elements are found then an empty list is immediately returned

Gets the value of the nodes attribute

Marks a checkbox as “checked”

Checks if the node has been selected

Chooses a radio button

Clears an input field. Input nodes are looked up by id, label text, or name. The node can also be passed in directly

Clicks a node

Fills in a “fillable” node with text. Input nodes are looked up by id, label text, or name. The specific node can also be passed in directly

Finds a specific DOM node on the page based on a css selector. Blocks until it either finds the node or until the max time is reached. By default only 1 node is expected to match the query. If more nodes are present then a count can be specified. By default only nodes that are visible on the page are returned

Matches the Node’s content with the provided text

Searches for CSS on the page

Searches for css that should not be on the page

Matches the Node’s value with the provided value

Selects an option from a select box. Searches for the select box by id, name or label, then finds the option by visible text

Gets the selected value of the element

Checks if the node has been selected. Alias for checked?(node)

Gets the Node’s text value

Unchecks a checkbox

Checks if the node is visible on the page

Types

locator :: Session.t | t
query :: String.t | {:xpath, String.t}
t :: %Wallaby.Node{id: String.t, session: Session.t}

Functions

all(locator, query)

Specs

all(locator, query) :: [t]

Finds all of the DOM nodes that match the css selector. If no elements are found then an empty list is immediately returned.

attr(node, name)

Specs

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

Gets the value of the nodes attribute.

check(node)

Specs

Marks a checkbox as “checked”.

check(session, query)
checked?(node)

Specs

checked?(t) :: boolean

Checks if the node has been selected.

choose(node)
choose(session, query)

Chooses a radio button.

clear(locator)
clear(session, query)

Clears an input field. Input nodes are looked up by id, label text, or name. The node can also be passed in directly.

click(locator)

Specs

click(t) :: Wallaby.Session.t
click(session, query)

Clicks a node.

fill_in(node, list)

Specs

fill_in(Wallaby.Node.t, [{:with, String.t}]) :: Wallaby.Session.t
fill_in(session, query, list)

Specs

fill_in(locator, query, [{:with, String.t}]) :: Wallaby.Session.t

Fills in a “fillable” node with text. Input nodes are looked up by id, label text, or name. The specific node can also be passed in directly.

find(locator, query, opts \\ [])

Specs

find(locator, query, Keyword.t) :: t | [t]

Finds a specific DOM node on the page based on a css selector. Blocks until it either finds the node or until the max time is reached. By default only 1 node is expected to match the query. If more nodes are present then a count can be specified. By default only nodes that are visible on the page are returned.

Selections can be scoped by providing a Node as the locator for the query.

has_content?(node, text)

Specs

has_content?(t, String.t) :: boolean

Matches the Node’s content with the provided text.

has_css?(locator, css)

Specs

has_css?(locator, String.t) :: boolean

Searches for CSS on the page.

has_no_css?(locator, css)

Specs

has_no_css?(locator, String.t) :: boolean

Searches for css that should not be on the page

has_value?(node, value)

Specs

has_value?(t, any) :: boolean

Matches the Node’s value with the provided value.

select(node, list)

Specs

select(Wallaby.Node.t, [{:option, query}]) :: Wallaby.Session.t
select(session, selector, list)

Specs

select(locator, String.t, [{:option, query}]) :: Wallaby.Session.t

Selects an option from a select box. Searches for the select box by id, name or label, then finds the option by visible text.

The specific node for the select box can also be passed in directly.

selected(node)

Specs

selected(t) :: any

Gets the selected value of the element.

For Checkboxes and Radio buttons it returns the selected option.

selected?(node)

Specs

selected?(t) :: boolean

Checks if the node has been selected. Alias for checked?(node)

text(node)

Specs

text(t) :: String.t

Gets the Node’s text value.

uncheck(node)

Specs

uncheck(t) :: t

Unchecks a checkbox.

uncheck(session, query)
visible?(node)

Specs

visible?(t) :: boolean

Checks if the node is visible on the page