wallaby v0.16.1 Wallaby.Query
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
Summary
Types
conditions()
conditions() :: [count: non_neg_integer, text: String.t, visible: boolean, minimum: non_neg_integer]
method()
method :: :css | :xpath | :link | :button | :fillable_field | :checkbox | :radio_button | :option | :select | :file_field
t()
t() :: %Wallaby.Query{conditions: conditions, html_validation: html_validation, method: method, result: result, selector: selector}