Typed locator, active-page, and captured-result assertion values executed by
Fluffy.Expect.expect/2.
Page and captured-result constructors use target prefixes such as
page_to_have_url/2 and response_to_have_status/3.
Import this module to use expect/2, not_/1, and all constructors.
For ExUnit-style names, use Fluffy.Assert.
Assertion constructors use fluent to_be_* names for states and to_have_*
names for properties.
Every expectation constructor accepts the shared timeout option. Captured-result
assertions inspect an already retained result immediately; their timeout option
does not wait for another event. Set the capture timeout on Fluffy.wait_for/4.
:timeout(non_neg_integer/0) - Maximum time in milliseconds to wait for the operation. Playwright browser bookkeeping and navigation synchronization use the session timeout separately.
to_be_checked/2 additionally accepts:
:timeout(non_neg_integer/0) - Maximum time in milliseconds to wait for the operation. Playwright browser bookkeeping and navigation synchronization use the session timeout separately.:checked(boolean/0) - Set to false to expect an unchecked control.:indeterminate(boolean/0) - Expect the browser-owned indeterminate state.
Summary
Locator assertions
Expects a checkbox or radio to have Playwright's checked state.
Functions
Executes an expectation and returns the unchanged or reconciled session.
Negates an expectation while preserving its target and options.
Assertions
Expects the captured dialog's action to equal the supplied value.
Expects the captured dialog's default value to equal the supplied value.
Expects the captured dialog's message to equal the supplied value.
Expects the captured dialog's prompt text to equal the supplied value.
Expects the captured dialog's type to equal the supplied value.
Expects the complete downloaded bytes to equal the supplied binary; no text decoding is performed.
Expects the captured download's content type to equal the supplied value.
Expects the download size in bytes.
Expects the captured download's suggested filename to equal the supplied value.
Expects the captured download URL to match a string, regex, URI predicate, or structured components.
Expects the captured navigation source URL to match a string, regex, URI predicate, or structured components.
Expects the captured navigation's status to equal the supplied value.
Expects the captured navigation URL to match a string, regex, URI predicate, or structured components.
Expects the active page to name the requested opener page.
Expects the active page's normalized main-resource status.
Expects the active page title to equal a string or match a regular expression.
Expects the active page to have the requested URL.
Expects the captured request headers to include every supplied key/value pair. Additional headers are allowed.
Expects the captured request's method to equal the supplied value.
Expects the captured request's page to equal the supplied value.
Expects the captured request's post data to equal the supplied value.
Expects the captured request's resource type to equal the supplied value.
Expects the captured request URL to match a string, regex, URI predicate, or structured components.
Expects the captured response headers to include every supplied key/value pair. Additional headers are allowed.
Expects the captured response's page to equal the supplied value.
Expects the HTTP method of the request that produced this response.
Expects the associated request payload to equal the supplied string. This does not inspect the response body.
Expects the captured response's resource type to equal the supplied value.
Expects the captured response's status to equal the supplied value.
Expects the captured response's status text to equal the supplied value.
Expects the captured response URL to match a string, regex, URI predicate, or structured components.
Locator assertions
@spec to_be_checked(Fluffy.Locator.t(), [checked_option()]) :: t()
Expects a checkbox or radio to have Playwright's checked state.
The default is checked. Pass checked: false for unchecked, or
indeterminate: true for the browser-owned mixed state. The indeterminate
state requires Playwright because it is a DOM property rather than HTML
state available to the Static or LiveView drivers.
@spec to_be_disabled(Fluffy.Locator.t(), [option()]) :: t()
@spec to_be_editable(Fluffy.Locator.t(), [option()]) :: t()
@spec to_be_enabled(Fluffy.Locator.t(), [option()]) :: t()
@spec to_be_focused(Fluffy.Locator.t(), [option()]) :: t()
@spec to_be_visible(Fluffy.Locator.t(), [option()]) :: t()
@spec to_have_count(Fluffy.Locator.t(), non_neg_integer(), [option()]) :: t()
@spec to_have_value(Fluffy.Locator.t(), String.t(), [option()]) :: t()
@spec to_have_values(Fluffy.Locator.t(), [term()], [option()]) :: t()
Types
@type checked_option() :: {:timeout, non_neg_integer()} | {:checked, boolean()} | {:indeterminate, boolean()}
@type kind() ::
:checked
| :count
| :disabled
| :editable
| :enabled
| :focused
| :opener
| :status
| :title
| :url
| :value
| :values
| :visible
| :download_content
| :download_content_type
| :download_size
| :download_suggested_filename
| :download_url
| :dialog_action
| :dialog_default_value
| :dialog_message
| :dialog_prompt_text
| :dialog_type
| :navigation_from_url
| :navigation_status
| :navigation_url
| :request_headers
| :request_method
| :request_page
| :request_post_data
| :request_resource_type
| :request_url
| :response_headers
| :response_method
| :response_page
| :response_post_data
| :response_resource_type
| :response_status
| :response_status_text
| :response_url
@type option() :: {:timeout, non_neg_integer()}
Functions
@spec expect(Fluffy.Session.t(), t(), [option()]) :: Fluffy.Session.t()
Executes an expectation and returns the unchanged or reconciled session.
Negates an expectation while preserving its target and options.
Assertions
Expects the captured dialog's action to equal the supplied value.
Expects the captured dialog's default value to equal the supplied value.
Expects the captured dialog's message to equal the supplied value.
Expects the captured dialog's prompt text to equal the supplied value.
Expects the captured dialog's type to equal the supplied value.
Expects the complete downloaded bytes to equal the supplied binary; no text decoding is performed.
Expects the captured download's content type to equal the supplied value.
@spec download_to_have_size(term(), non_neg_integer(), [option()]) :: t()
Expects the download size in bytes.
Expects the captured download's suggested filename to equal the supplied value.
@spec download_to_have_url(term(), Fluffy.Page.url_expectation(), [option()]) :: t()
Expects the captured download URL to match a string, regex, URI predicate, or structured components.
Strings match exactly and regexes match against the complete captured URL.
Relative strings are not resolved. Structured keywords use the same path,
query, and fragment rules as Fluffy.Expect.page_to_have_url/2.
Function predicates receive a %URI{}.
Expects the active page to name the requested opener page.
@spec page_to_have_status(non_neg_integer(), [option()]) :: t()
Expects the active page's normalized main-resource status.
@spec page_to_have_title(Fluffy.Page.title_expectation(), [option()]) :: t()
Expects the active page title to equal a string or match a regular expression.
Like Playwright's toHaveTitle, the assertion retries on Live and Playwright
pages and normalizes whitespace before matching.
Options
:timeout(non_neg_integer/0) - Maximum time in milliseconds to wait for the operation. Playwright browser bookkeeping and navigation synchronization use the session timeout separately.
@spec page_to_have_url(Fluffy.Page.url_expectation(), [option()]) :: t()
Expects the active page to have the requested URL.
A string matches the complete canonical absolute URL after resolving a
relative value against the session base URL. A regular expression matches
that complete serialized URL. A function receives a %URI{} and returns a boolean.
Keep predicates quick and nonblocking.
A keyword list selects structured components. :path and :fragment are
exact serialized component values; omit either to ignore it. :fragment
excludes the leading #, and fragment: nil requires no fragment.
:query is a map from decoded parameter names to one value or an ordered
list of repeated values. Ordering between distinct names is ignored while
repeated-value order is retained. Bare names and names with an empty value
both decode to ""; + and %20 both decode to a space. Exact mode is the
default. query_mode: :subset permits unrelated names but still requires
the complete ordered value list for each requested name.
Structured components
:path(String.t/0) - Serialized URL pathname to match exactly.:query- Decoded query names and their ordered value or values.:query_mode- Require the complete query or allow unrelated parameter names. The default value is:exact.:fragment- Serialized fragment without#; nil requires no fragment.
Assertion options
:timeout(non_neg_integer/0) - Maximum time in milliseconds to wait for the operation. Playwright browser bookkeeping and navigation synchronization use the session timeout separately.
Expects the captured request headers to include every supplied key/value pair. Additional headers are allowed.
Expects the captured request's method to equal the supplied value.
Expects the captured request's page to equal the supplied value.
Expects the captured request's post data to equal the supplied value.
Expects the captured request's resource type to equal the supplied value.
@spec request_to_have_url(term(), Fluffy.Page.url_expectation(), [option()]) :: t()
Expects the captured request URL to match a string, regex, URI predicate, or structured components.
Strings match exactly and regexes match against the complete captured URL.
Relative strings are not resolved. Structured keywords use the same path,
query, and fragment rules as Fluffy.Expect.page_to_have_url/2.
Function predicates receive a %URI{}.
Expects the captured response headers to include every supplied key/value pair. Additional headers are allowed.
Expects the captured response's page to equal the supplied value.
Expects the HTTP method of the request that produced this response.
Expects the associated request payload to equal the supplied string. This does not inspect the response body.
Expects the captured response's resource type to equal the supplied value.
Expects the captured response's status to equal the supplied value.
Expects the captured response's status text to equal the supplied value.
@spec response_to_have_url(term(), Fluffy.Page.url_expectation(), [option()]) :: t()
Expects the captured response URL to match a string, regex, URI predicate, or structured components.
Strings match exactly and regexes match against the complete captured URL.
Relative strings are not resolved. Structured keywords use the same path,
query, and fragment rules as Fluffy.Expect.page_to_have_url/2.
Function predicates receive a %URI{}.