wallaby v0.10.0 Wallaby.Node.Query

Provides the query DSL.

Queries are used to locate and retrieve DOM nodes. The standard method for querying is css selectors:

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

If more complex querying is needed then its possible to use XPath:

find(page, {:xpath, "//input"})

By default finders only work with elements that would be visible to a real user.

Scoping

Finders can also be chained together to provide scoping:

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

Form elements

There are several custom finders for locating form elements. Each of these allows finding by their name, id text, or label text. This allows for more robust querying and decouples the query from presentation selectors like css classes.

Query Options

All of the query operations accept the following options:

  • :count - The number of elements that should be found (default: 1).
  • :visible - Determines if the query should return only visible elements (default: true).
  • :text - Text that should be found inside the element.

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

Builds a query struct to send to webdriver

Finds a button by its id, name, or label text

Finds a checkbox field by its id, name, or label text

Locates a text field or textarea by its id, name, placeholder, or label text

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

Finds a link field by its id, name, or text. If the link contains an image then it can find the link by the image’s alt text

Finds an option field by its option text

Locates a radio button by its id, name, or label text

Finds a select field by its id, name, or label text

Types

errors :: list
locator :: String.t | {atom, String.t}
opts :: list
query :: {atom, String.t}
t :: %Wallaby.Node.Query{conditions: opts, errors: errors, locator: locator, parent: parent, query: term, result: result}

Functions

all(parent, locator, opts)

Specs

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

Options

See the “Query Options” section in the module documentation

build_query(parent, locator, opts)

Specs

build_query(parent, locator, opts) :: t

Builds a query struct to send to webdriver.

button(parent, locator, opts)

Specs

button(parent, locator, opts) :: result

Finds a button by its id, name, or label text.

Options

See the “Query Options” section in the module documentation

checkbox(parent, locator, opts)

Specs

checkbox(parent, locator, opts) :: result

Finds a checkbox field by its id, name, or label text.

Options

See the “Query Options” section in the module documentation

fillable_field(parent, locator, opts)

Specs

fillable_field(parent, locator, opts) :: result

Locates a text field or textarea by its id, name, placeholder, or label text.

Options

See the “Query Options” section in the module documentation

find(parent, locator, opts)

Specs

find(parent, locator, opts) :: result

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.

Options

See the “Query Options” section in the module documentation

link(parent, locator, opts)

Specs

link(parent, locator, opts) :: result

Finds a link field by its id, name, or text. If the link contains an image then it can find the link by the image’s alt text.

Options

See the “Query Options” section in the module documentation

max_time_exceeded?(start_time)
option(parent, locator, opts)

Specs

option(parent, locator, opts) :: result

Finds an option field by its option text.

Options

See the “Query Options” section in the module documentation

radio_button(parent, locator, opts)

Specs

radio_button(parent, locator, opts) :: result

Locates a radio button by its id, name, or label text.

Options

See the “Query Options” section in the module documentation

select(parent, locator, opts)

Specs

select(parent, locator, opts) :: result

Finds a select field by its id, name, or label text.

Options

See the “Query Options” section in the module documentation