wallaby v0.19.1 Wallaby.Query View Source

Provides the query DSL.

Queries are used to locate and retrieve DOM elements from a browser (see Wallaby.Browser). You create queries like so:

Query.css(".some-css")
Query.xpath(".//input")

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.text_field("My Name")
Query.checkbox("Checkbox")
Query.select("A Fancy Select Box")

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 (default: nil).

Re-using queries

It is often convenient to re-use queries. The easiest way is to use module attributes:

@name_field Query.text_field("User Name")
@submit_button Query.button("Save")

If the queries need to be dynamic then you should create a module that encapsulates the queries as functions:

defmodule TodoListPage do
  def todo_list() do
    Query.css(".todo-list")
  end

  def todos(count) do
    Query.css(".todo", count: count)
  end
end

Link to this section Summary

Link to this section Types

Link to this type compiled() View Source
compiled() :: {:xpath | :css, String.t}
Link to this type conditions() View Source
conditions() :: [count: non_neg_integer, text: String.t, visible: boolean, minimum: non_neg_integer]
Link to this type html_validation() View Source
html_validation() :: :bad_label | :button_type | nil
Link to this type method() View Source
method ::
  :css |
  :xpath |
  :link |
  :button |
  :fillable_field |
  :checkbox |
  :radio_button |
  :option |
  :select |
  :file_field
Link to this type opts() View Source
opts() :: [...]
Link to this type t() View Source
t() :: %Wallaby.Query{conditions: conditions, html_validation: html_validation, method: method, result: result, selector: selector}

Link to this section Functions

Link to this function button(selector, opts \\ []) View Source
Link to this function checkbox(selector, opts \\ []) View Source
Link to this function css(selector, opts \\ []) View Source
Link to this function file_field(selector, opts \\ []) View Source
Link to this function fillable_field(selector, opts \\ []) View Source
Link to this function link(selector, opts \\ []) View Source
Link to this function matches_count?(map, count) View Source
Link to this function option(selector, opts \\ []) View Source
Link to this function radio_button(selector, opts \\ []) View Source
Link to this function select(selector, opts \\ []) View Source
Link to this function text(selector, opts \\ []) View Source
Link to this function text_field(selector, opts \\ []) View Source
Link to this function xpath(selector, opts \\ []) View Source