Web-first assertions: the methods of LocatorAssertions, PageAssertions and APIResponseAssertions, as functions of their receiver.
expect(locator).toHaveText(expected) is to_have_text(locator, expected), expect(locator).not.toHaveText(expected) is not_to_have_text(locator, expected) or locator |> not_() |> to_have_text(expected). They retry until the expectation is met or the timeout (5 seconds by default, see Configuration below) passes, then return :ok or {:error, %PlaywrightEx.ExpectError{}} whose matcherResult mirrors JS; the bang forms raise the PlaywrightEx.ExpectError (Testing with ExUnit shows how to wrap it in an ExUnit.AssertionError).
The LocatorAssertions class provides assertion methods that can be used to make assertions about the Locator state in the tests.
test "status becomes submitted", %{page: page} do
# ...
Page.get_by_role(page, :button) |> Locator.click!()
Page.locator(page, ".status") |> Expect.to_have_text!("Submitted")
endConfiguration
The expect part of upstream's playwright.config.ts, read when a matcher runs (so an
Application.put_env/3 in test_helper.exs applies too):
config :playwright_ex, :expect, timeout: 10_000, update_snapshots: :missingThe keys (other keys raise ArgumentError, at application start for the config files):
:timeout- Default timeout of the matchers in milliseconds,0or:infinityfor no timeout. Defaults to5000. Atimeout:option of a matcher wins.:update_snapshots- Whento_have_screenshotandto_match_aria_snapshotwrite snapshots::all,:changed,:missing,:noneor:default(the default: write missing ones). A screenshot, or an aria snapshot withpath:, is written to itspath. An inline aria snapshot can't be written into the test source without a test runner, so where upstream suggests a rebaseline (an empty snapshot, or any under:allor a mismatch under:changed) the matcher fails with the new snapshot in its message.:ignore_snapshots- Skip the snapshot matchers. Defaults tofalse.:to_have_screenshot,:to_match_aria_snapshot- Defaults for their options, maps with the JS keys (%{maxDiffPixels: 10},%{children: "equal"}), as upstream's config.
Since Playwright 1.17.
The examples alias the modules they use (alias PlaywrightEx.{Locator, Page}).
Summary
Types
Options of not_to_be_attached/2, see its docs.
Options of not_to_be_checked/2, see its docs.
Options of not_to_be_disabled/2, see its docs.
Options of not_to_be_editable/2, see its docs.
Options of not_to_be_empty/2, see its docs.
Options of not_to_be_enabled/2, see its docs.
Options of not_to_be_focused/2, see its docs.
Options of not_to_be_hidden/2, see its docs.
Options of not_to_be_in_viewport/2, see its docs.
Options of not_to_be_visible/2, see its docs.
Options of not_to_contain_class/3, see its docs.
Options of not_to_contain_text/3, see its docs.
Options of not_to_have_accessible_description/3, see its docs.
Options of not_to_have_accessible_error_message/3, see its docs.
Options of not_to_have_accessible_name/3, see its docs.
Options of not_to_have_attribute/4, see its docs.
Options of not_to_have_class/3, see its docs.
Options of not_to_have_count/3, see its docs.
Options of not_to_have_css/4, see its docs.
Options of not_to_have_id/3, see its docs.
Options of not_to_have_js_property/4, see its docs.
Options of not_to_have_role/3, see its docs.
Options of not_to_have_screenshot/2, see its docs.
Options of not_to_have_text/3, see its docs.
Options of not_to_have_title/3, see its docs.
Options of not_to_have_url/3, see its docs.
Options of not_to_have_value/3, see its docs.
Options of not_to_have_values/3, see its docs.
Options of not_to_match_aria_snapshot/3, see its docs.
A negated receiver of any matcher.
Options of to_be_attached/2, see its docs.
Options of to_be_checked/2, see its docs.
Options of to_be_disabled/2, see its docs.
Options of to_be_editable/2, see its docs.
Options of to_be_empty/2, see its docs.
Options of to_be_enabled/2, see its docs.
Options of to_be_focused/2, see its docs.
Options of to_be_hidden/2, see its docs.
Options of to_be_in_viewport/2, see its docs.
Options of to_be_visible/2, see its docs.
Options of to_contain_class/3, see its docs.
Options of to_contain_text/3, see its docs.
Options of to_have_accessible_description/3, see its docs.
Options of to_have_accessible_error_message/3, see its docs.
Options of to_have_accessible_name/3, see its docs.
Options of to_have_attribute/4, see its docs.
Options of to_have_class/3, see its docs.
Options of to_have_count/3, see its docs.
Options of to_have_css/4, see its docs.
Options of to_have_id/3, see its docs.
Options of to_have_js_property/4, see its docs.
Options of to_have_role/3, see its docs.
Options of to_have_screenshot/2, see its docs.
Options of to_have_text/3, see its docs.
Options of to_have_title/3, see its docs.
Options of to_have_url/3, see its docs.
Options of to_have_value/3, see its docs.
Options of to_have_values/3, see its docs.
Options of to_match_aria_snapshot/3, see its docs.
Functions
Makes the assertion check for the opposite condition.
The opposite of to_be_attached/2: expect(x).not.toBeAttached(...) in JS.
Like not_to_be_attached/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_be_checked/2: expect(x).not.toBeChecked(...) in JS.
Like not_to_be_checked/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_be_disabled/2: expect(x).not.toBeDisabled(...) in JS.
Like not_to_be_disabled/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_be_editable/2: expect(x).not.toBeEditable(...) in JS.
Like not_to_be_editable/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_be_empty/2: expect(x).not.toBeEmpty(...) in JS.
Like not_to_be_empty/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_be_enabled/2: expect(x).not.toBeEnabled(...) in JS.
Like not_to_be_enabled/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_be_focused/2: expect(x).not.toBeFocused(...) in JS.
Like not_to_be_focused/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_be_hidden/2: expect(x).not.toBeHidden(...) in JS.
Like not_to_be_hidden/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_be_in_viewport/2: expect(x).not.toBeInViewport(...) in JS.
Like not_to_be_in_viewport/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_be_ok/1: expect(x).not.toBeOK(...) in JS.
Like not_to_be_ok/1, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_be_visible/2: expect(x).not.toBeVisible(...) in JS.
Like not_to_be_visible/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_contain_class/3: expect(x).not.toContainClass(...) in JS.
Like not_to_contain_class/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_contain_text/3: expect(x).not.toContainText(...) in JS.
Like not_to_contain_text/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_accessible_description/3: expect(x).not.toHaveAccessibleDescription(...) in JS.
Like not_to_have_accessible_description/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_accessible_error_message/3: expect(x).not.toHaveAccessibleErrorMessage(...) in JS.
Like not_to_have_accessible_error_message/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_accessible_name/3: expect(x).not.toHaveAccessibleName(...) in JS.
Like not_to_have_accessible_name/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_attribute/4: expect(x).not.toHaveAttribute(...) in JS.
Like not_to_have_attribute/4, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_class/3: expect(x).not.toHaveClass(...) in JS.
Like not_to_have_class/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_count/3: expect(x).not.toHaveCount(...) in JS.
Like not_to_have_count/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_css/4: expect(x).not.toHaveCSS(...) in JS.
Like not_to_have_css/4, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_id/3: expect(x).not.toHaveId(...) in JS.
Like not_to_have_id/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_js_property/4: expect(x).not.toHaveJSProperty(...) in JS.
Like not_to_have_js_property/4, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_role/3: expect(x).not.toHaveRole(...) in JS.
Like not_to_have_role/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_screenshot/2: expect(x).not.toHaveScreenshot(...) in JS.
Like not_to_have_screenshot/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_text/3: expect(x).not.toHaveText(...) in JS.
Like not_to_have_text/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_title/3: expect(x).not.toHaveTitle(...) in JS.
Like not_to_have_title/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_url/3: expect(x).not.toHaveURL(...) in JS.
Like not_to_have_url/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_value/3: expect(x).not.toHaveValue(...) in JS.
Like not_to_have_value/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_have_values/3: expect(x).not.toHaveValues(...) in JS.
Like not_to_have_values/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
The opposite of to_match_aria_snapshot/3: expect(x).not.toMatchAriaSnapshot(...) in JS.
Like not_to_match_aria_snapshot/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Like to_be_attached/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to a checked input.
Like to_be_checked/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to a disabled element. Element is disabled if it has "disabled" attribute
or is disabled via 'aria-disabled'.
Note that only native control elements such as HTML button, input, select, textarea, option, optgroup
can be disabled by setting "disabled" attribute. "disabled" attribute on other elements is ignored
by the browser.
Like to_be_disabled/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an editable element.
Like to_be_editable/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an empty editable element or to a DOM node that has no text.
Like to_be_empty/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an enabled element.
Like to_be_enabled/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to a focused DOM node.
Like to_be_focused/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures that Locator either does not resolve to any DOM node, or resolves to a non-visible one.
Like to_be_hidden/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an element that intersects viewport, according to the intersection observer API.
Like to_be_in_viewport/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the response status code is within 200..299 range.
Like to_be_ok/1, but raises PlaywrightEx.ExpectError when the expectation is not met.
Like to_be_visible/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an element with given CSS classes. All classes from the asserted value, separated by spaces, must be present in the Element.classList in any order.
Like to_contain_class/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an element that contains the given text. All nested elements will be considered when computing the text content of the element. You can use regular expressions for the value as well.
Like to_contain_text/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an element with a given accessible description.
Like to_have_accessible_description/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an element with a given aria errormessage.
Like to_have_accessible_error_message/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an element with a given accessible name.
Like to_have_accessible_name/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an element with given attribute.
Like to_have_attribute/4, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an element with given CSS classes. When a string is provided, it must fully match the element's class attribute. To match individual classes use PlaywrightEx.Expect.to_contain_class/3.
Like to_have_class/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator resolves to an exact number of DOM nodes.
Like to_have_count/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator resolves to an element with the given computed CSS style.
Like to_have_css/4, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an element with the given DOM Node ID.
Like to_have_id/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an element with given JavaScript property. Note that this property can be
of a primitive type as well as a plain serializable JavaScript object.
Like to_have_js_property/4, but raises PlaywrightEx.ExpectError when the expectation is not met.
Like to_have_role/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
This function will wait until two consecutive locator screenshots yield the same result, and then compare the last screenshot with the expectation.
Like to_have_screenshot/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an element with the given text. All nested elements will be considered when computing the text content of the element. You can use regular expressions for the value as well.
Like to_have_text/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the page has the given title.
Like to_have_title/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the page is navigated to the given URL.
Like to_have_url/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to an element with the given input value. You can use regular expressions for the value as well.
Like to_have_value/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Ensures the Locator points to multi-select/combobox (i.e. a select with the multiple attribute) and the specified values are selected.
Like to_have_values/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Asserts that the target element matches the given accessibility snapshot.
Like to_match_aria_snapshot/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
Types
@type not_to_be_attached_options() :: [ attached: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:attached) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_be_attached/2, see its docs.
@type not_to_be_checked_options() :: [ checked: boolean(), indeterminate: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:checked) => boolean(), optional(:indeterminate) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_be_checked/2, see its docs.
@type not_to_be_disabled_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_be_disabled/2, see its docs.
@type not_to_be_editable_options() :: [ editable: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:editable) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_be_editable/2, see its docs.
@type not_to_be_empty_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_be_empty/2, see its docs.
@type not_to_be_enabled_options() :: [ enabled: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:enabled) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_be_enabled/2, see its docs.
@type not_to_be_focused_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_be_focused/2, see its docs.
@type not_to_be_in_viewport_options() :: [ ratio: number(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:ratio) => number(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_be_in_viewport/2, see its docs.
@type not_to_be_visible_options() :: [ signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity, visible: boolean() ] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity, optional(:visible) => boolean() }
Options of not_to_be_visible/2, see its docs.
@type not_to_contain_class_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_contain_class/3, see its docs.
@type not_to_contain_text_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity, use_inner_text: boolean() ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity, optional(:use_inner_text) => boolean() }
Options of not_to_contain_text/3, see its docs.
@type not_to_have_accessible_description_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_accessible_description/3, see its docs.
@type not_to_have_accessible_error_message_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_accessible_error_message/3, see its docs.
@type not_to_have_accessible_name_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_accessible_name/3, see its docs.
@type not_to_have_attribute_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_attribute/4, see its docs.
@type not_to_have_class_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_class/3, see its docs.
@type not_to_have_count_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_count/3, see its docs.
@type not_to_have_css_options() :: [ pseudo: :before | :after, signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:pseudo) => :before | :after, optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_css/4, see its docs.
@type not_to_have_id_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_id/3, see its docs.
@type not_to_have_js_property_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_js_property/4, see its docs.
@type not_to_have_role_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_role/3, see its docs.
@type not_to_have_screenshot_options() :: [ path: String.t(), animations: :disabled | :allow, caret: :hide | :initial, mask: [PlaywrightEx.Locator.t()], mask_color: String.t(), max_diff_pixel_ratio: number(), max_diff_pixels: integer(), omit_background: boolean(), scale: :css | :device, signal: PlaywrightEx.AbortSignal.t(), style_path: String.t() | [String.t()], threshold: number(), timeout: number() | :infinity, clip: %{x: number(), y: number(), width: number(), height: number()}, full_page: boolean() ] | %{ optional(:path) => String.t(), optional(:animations) => :disabled | :allow, optional(:caret) => :hide | :initial, optional(:mask) => [PlaywrightEx.Locator.t()], optional(:mask_color) => String.t(), optional(:max_diff_pixel_ratio) => number(), optional(:max_diff_pixels) => integer(), optional(:omit_background) => boolean(), optional(:scale) => :css | :device, optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:style_path) => String.t() | [String.t()], optional(:threshold) => number(), optional(:timeout) => number() | :infinity, optional(:clip) => %{ x: number(), y: number(), width: number(), height: number() }, optional(:full_page) => boolean() }
Options of not_to_have_screenshot/2, see its docs.
@type not_to_have_text_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity, use_inner_text: boolean() ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity, optional(:use_inner_text) => boolean() }
Options of not_to_have_text/3, see its docs.
@type not_to_have_title_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_title/3, see its docs.
@type not_to_have_url_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_url/3, see its docs.
@type not_to_have_value_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_value/3, see its docs.
@type not_to_have_values_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_have_values/3, see its docs.
@type not_to_match_aria_snapshot_options() :: [ path: String.t(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:path) => String.t(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of not_to_match_aria_snapshot/3, see its docs.
@type t() :: t( PlaywrightEx.Locator.t() | PlaywrightEx.Page.t() | PlaywrightEx.APIResponse.t() )
A negated receiver of any matcher.
@type t(actual) :: %PlaywrightEx.Expect{actual: actual, isNot: true}
A negated receiver (not_/1): expect(actual).not in JS.
@type to_be_attached_options() :: [ attached: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:attached) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_be_attached/2, see its docs.
@type to_be_checked_options() :: [ checked: boolean(), indeterminate: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:checked) => boolean(), optional(:indeterminate) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_be_checked/2, see its docs.
@type to_be_disabled_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_be_disabled/2, see its docs.
@type to_be_editable_options() :: [ editable: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:editable) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_be_editable/2, see its docs.
@type to_be_empty_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_be_empty/2, see its docs.
@type to_be_enabled_options() :: [ enabled: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:enabled) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_be_enabled/2, see its docs.
@type to_be_focused_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_be_focused/2, see its docs.
@type to_be_in_viewport_options() :: [ ratio: number(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:ratio) => number(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_be_in_viewport/2, see its docs.
@type to_be_visible_options() :: [ signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity, visible: boolean() ] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity, optional(:visible) => boolean() }
Options of to_be_visible/2, see its docs.
@type to_contain_class_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_contain_class/3, see its docs.
@type to_contain_text_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity, use_inner_text: boolean() ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity, optional(:use_inner_text) => boolean() }
Options of to_contain_text/3, see its docs.
@type to_have_accessible_description_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_accessible_description/3, see its docs.
@type to_have_accessible_error_message_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_accessible_error_message/3, see its docs.
@type to_have_accessible_name_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_accessible_name/3, see its docs.
@type to_have_attribute_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_attribute/4, see its docs.
@type to_have_class_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_class/3, see its docs.
@type to_have_count_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_count/3, see its docs.
@type to_have_css_options() :: [ pseudo: :before | :after, signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:pseudo) => :before | :after, optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_css/4, see its docs.
@type to_have_id_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_id/3, see its docs.
@type to_have_js_property_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_js_property/4, see its docs.
@type to_have_role_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_role/3, see its docs.
@type to_have_screenshot_options() :: [ path: String.t(), animations: :disabled | :allow, caret: :hide | :initial, mask: [PlaywrightEx.Locator.t()], mask_color: String.t(), max_diff_pixel_ratio: number(), max_diff_pixels: integer(), omit_background: boolean(), scale: :css | :device, signal: PlaywrightEx.AbortSignal.t(), style_path: String.t() | [String.t()], threshold: number(), timeout: number() | :infinity, clip: %{x: number(), y: number(), width: number(), height: number()}, full_page: boolean() ] | %{ optional(:path) => String.t(), optional(:animations) => :disabled | :allow, optional(:caret) => :hide | :initial, optional(:mask) => [PlaywrightEx.Locator.t()], optional(:mask_color) => String.t(), optional(:max_diff_pixel_ratio) => number(), optional(:max_diff_pixels) => integer(), optional(:omit_background) => boolean(), optional(:scale) => :css | :device, optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:style_path) => String.t() | [String.t()], optional(:threshold) => number(), optional(:timeout) => number() | :infinity, optional(:clip) => %{ x: number(), y: number(), width: number(), height: number() }, optional(:full_page) => boolean() }
Options of to_have_screenshot/2, see its docs.
@type to_have_text_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity, use_inner_text: boolean() ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity, optional(:use_inner_text) => boolean() }
Options of to_have_text/3, see its docs.
@type to_have_title_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_title/3, see its docs.
@type to_have_url_options() :: [ ignore_case: boolean(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:ignore_case) => boolean(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_url/3, see its docs.
@type to_have_value_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_value/3, see its docs.
@type to_have_values_options() :: [signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity] | %{ optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_have_values/3, see its docs.
@type to_match_aria_snapshot_options() :: [ path: String.t(), signal: PlaywrightEx.AbortSignal.t(), timeout: number() | :infinity ] | %{ optional(:path) => String.t(), optional(:signal) => PlaywrightEx.AbortSignal.t(), optional(:timeout) => number() | :infinity }
Options of to_match_aria_snapshot/3, see its docs.
Functions
@spec not_(actual) :: t(actual) when actual: PlaywrightEx.Locator.t() | PlaywrightEx.Page.t() | PlaywrightEx.APIResponse.t()
Makes the assertion check for the opposite condition.
Usage
For example, this code tests that the Locator doesn't contain text "error":
locator |> Expect.not_() |> Expect.to_contain_text!("error")In Elixir, not_/1 wraps the receiver, which every matcher takes too: locator |> Expect.not_() |> Expect.to_contain_text("error") is Expect.not_to_contain_text(locator, "error"). As JS has no expect(x).not.not, a negated receiver is not negated again: not_/1 and the not_to_* matchers raise ArgumentError for one.
Since Playwright 1.20.
@spec not_to_be_attached(PlaywrightEx.Locator.t(), not_to_be_attached_options()) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_be_attached/2: expect(x).not.toBeAttached(...) in JS.
Since Playwright 1.33.
Options
:attached(boolean/0):signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_be_attached!(PlaywrightEx.Locator.t(), not_to_be_attached_options()) :: :ok
Like not_to_be_attached/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_be_checked(PlaywrightEx.Locator.t(), not_to_be_checked_options()) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_be_checked/2: expect(x).not.toBeChecked(...) in JS.
Since Playwright 1.20.
Options
:checked(boolean/0) - Provides state to assert for. Asserts for input to be checked by default. This option can't be used when:indeterminateis set to true.:indeterminate(boolean/0) - Since Playwright 1.50. Asserts that the element is in the indeterminate (mixed) state. Only supported for checkboxes and radio buttons. This option can't be true when:checkedis provided.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_be_checked!(PlaywrightEx.Locator.t(), not_to_be_checked_options()) :: :ok
Like not_to_be_checked/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_be_disabled(PlaywrightEx.Locator.t(), not_to_be_disabled_options()) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_be_disabled/2: expect(x).not.toBeDisabled(...) in JS.
Since Playwright 1.20.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_be_disabled!(PlaywrightEx.Locator.t(), not_to_be_disabled_options()) :: :ok
Like not_to_be_disabled/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_be_editable(PlaywrightEx.Locator.t(), not_to_be_editable_options()) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_be_editable/2: expect(x).not.toBeEditable(...) in JS.
Since Playwright 1.20.
Options
:editable(boolean/0) - Since Playwright 1.26.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_be_editable!(PlaywrightEx.Locator.t(), not_to_be_editable_options()) :: :ok
Like not_to_be_editable/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_be_empty(PlaywrightEx.Locator.t(), not_to_be_empty_options()) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_be_empty/2: expect(x).not.toBeEmpty(...) in JS.
Since Playwright 1.20.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_be_empty!(PlaywrightEx.Locator.t(), not_to_be_empty_options()) :: :ok
Like not_to_be_empty/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_be_enabled(PlaywrightEx.Locator.t(), not_to_be_enabled_options()) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_be_enabled/2: expect(x).not.toBeEnabled(...) in JS.
Since Playwright 1.20.
Options
:enabled(boolean/0) - Since Playwright 1.26.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_be_enabled!(PlaywrightEx.Locator.t(), not_to_be_enabled_options()) :: :ok
Like not_to_be_enabled/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_be_focused(PlaywrightEx.Locator.t(), not_to_be_focused_options()) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_be_focused/2: expect(x).not.toBeFocused(...) in JS.
Since Playwright 1.20.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_be_focused!(PlaywrightEx.Locator.t(), not_to_be_focused_options()) :: :ok
Like not_to_be_focused/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_be_in_viewport(PlaywrightEx.Locator.t(), not_to_be_in_viewport_options()) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_be_in_viewport/2: expect(x).not.toBeInViewport(...) in JS.
Since Playwright 1.31.
Options
:ratio(number/0) - The minimal ratio of the element to intersect viewport. If equals to0, then element should intersect viewport at any positive ratio. Defaults to0.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_be_in_viewport!( PlaywrightEx.Locator.t(), not_to_be_in_viewport_options() ) :: :ok
Like not_to_be_in_viewport/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_be_ok(PlaywrightEx.APIResponse.t()) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_be_ok/1: expect(x).not.toBeOK(...) in JS.
Since Playwright 1.18.
@spec not_to_be_ok!(PlaywrightEx.APIResponse.t()) :: :ok
Like not_to_be_ok/1, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_be_visible(PlaywrightEx.Locator.t(), not_to_be_visible_options()) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_be_visible/2: expect(x).not.toBeVisible(...) in JS.
Since Playwright 1.20.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.:visible(boolean/0) - Since Playwright 1.26.
@spec not_to_be_visible!(PlaywrightEx.Locator.t(), not_to_be_visible_options()) :: :ok
Like not_to_be_visible/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_contain_class( PlaywrightEx.Locator.t(), String.t() | [String.t()], not_to_contain_class_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_contain_class/3: expect(x).not.toContainClass(...) in JS.
Since Playwright 1.52.
Arguments
expected- A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_contain_class!( PlaywrightEx.Locator.t(), String.t() | [String.t()], not_to_contain_class_options() ) :: :ok
Like not_to_contain_class/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_contain_text( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], not_to_contain_text_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_contain_text/3: expect(x).not.toContainText(...) in JS.
Since Playwright 1.20.
Arguments
expected- Expected substring or RegExp or a list of those.
Options
:ignore_case(boolean/0) - Since Playwright 1.23. Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression flag if specified.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.:use_inner_text(boolean/0) - Whether to useelement.innerTextinstead ofelement.textContentwhen retrieving DOM node text.
@spec not_to_contain_text!( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], not_to_contain_text_options() ) :: :ok
Like not_to_contain_text/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_accessible_description( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_accessible_description_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_accessible_description/3: expect(x).not.toHaveAccessibleDescription(...) in JS.
Since Playwright 1.44.
Arguments
description- Expected accessible description.
Options
:ignore_case(boolean/0) - Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression flag if specified.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_accessible_description!( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_accessible_description_options() ) :: :ok
Like not_to_have_accessible_description/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_accessible_error_message( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_accessible_error_message_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_accessible_error_message/3: expect(x).not.toHaveAccessibleErrorMessage(...) in JS.
Since Playwright 1.50.
Arguments
error_message- Expected accessible error message.
Options
:ignore_case(boolean/0) - Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression flag if specified.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_accessible_error_message!( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_accessible_error_message_options() ) :: :ok
Like not_to_have_accessible_error_message/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_accessible_name( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_accessible_name_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_accessible_name/3: expect(x).not.toHaveAccessibleName(...) in JS.
Since Playwright 1.44.
Arguments
name- Expected accessible name.
Options
:ignore_case(boolean/0) - Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression flag if specified.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_accessible_name!( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_accessible_name_options() ) :: :ok
Like not_to_have_accessible_name/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_attribute( PlaywrightEx.Locator.t(), String.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | nil, not_to_have_attribute_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_attribute/4: expect(x).not.toHaveAttribute(...) in JS.
Since Playwright 1.20.
Arguments
name- Attribute name.value- Expected attribute value.
Options
The options may take the place of value, which is then nil.
:ignore_case(boolean/0) - Since Playwright 1.40. Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression flag if specified.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_attribute!( PlaywrightEx.Locator.t(), String.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | nil, not_to_have_attribute_options() ) :: :ok
Like not_to_have_attribute/4, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_class( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], not_to_have_class_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_class/3: expect(x).not.toHaveClass(...) in JS.
Since Playwright 1.20.
Arguments
expected- Expected class or RegExp or a list of those.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_class!( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], not_to_have_class_options() ) :: :ok
Like not_to_have_class/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_count( PlaywrightEx.Locator.t(), integer(), not_to_have_count_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_count/3: expect(x).not.toHaveCount(...) in JS.
Since Playwright 1.20.
Arguments
count- Expected count.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_count!( PlaywrightEx.Locator.t(), integer(), not_to_have_count_options() ) :: :ok
Like not_to_have_count/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_css( PlaywrightEx.Locator.t(), String.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_css_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_css/4: expect(x).not.toHaveCSS(...) in JS.
Since Playwright 1.20.
Arguments
name- CSS property name.value- CSS property value.
Options
:pseudo(:before|:after) - Since Playwright 1.60. Pseudo-element to read computed styles from.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_css!( PlaywrightEx.Locator.t(), String.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_css_options() ) :: :ok
Like not_to_have_css/4, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_id( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_id_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_id/3: expect(x).not.toHaveId(...) in JS.
Since Playwright 1.20.
Arguments
id- Element id.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_id!( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_id_options() ) :: :ok
Like not_to_have_id/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_js_property( PlaywrightEx.Locator.t(), String.t(), term(), not_to_have_js_property_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_js_property/4: expect(x).not.toHaveJSProperty(...) in JS.
Since Playwright 1.20.
Arguments
name- Property name.value- Property value.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_js_property!( PlaywrightEx.Locator.t(), String.t(), term(), not_to_have_js_property_options() ) :: :ok
Like not_to_have_js_property/4, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_role( PlaywrightEx.Locator.t(), :alert | :alertdialog | :application | :article | :banner | :blockquote | :button | :caption | :cell | :checkbox | :code | :columnheader | :combobox | :complementary | :contentinfo | :definition | :deletion | :dialog | :directory | :document | :emphasis | :feed | :figure | :form | :generic | :grid | :gridcell | :group | :heading | :img | :insertion | :link | :list | :listbox | :listitem | :log | :main | :marquee | :math | :meter | :menu | :menubar | :menuitem | :menuitemcheckbox | :menuitemradio | :navigation | :none | :note | :option | :paragraph | :presentation | :progressbar | :radio | :radiogroup | :region | :row | :rowgroup | :rowheader | :scrollbar | :search | :searchbox | :separator | :slider | :spinbutton | :status | :strong | :subscript | :superscript | :switch | :tab | :table | :tablist | :tabpanel | :term | :textbox | :time | :timer | :toolbar | :tooltip | :tree | :treegrid | :treeitem, not_to_have_role_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_role/3: expect(x).not.toHaveRole(...) in JS.
Since Playwright 1.44.
Arguments
role- Required aria role.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_role!( PlaywrightEx.Locator.t(), :alert | :alertdialog | :application | :article | :banner | :blockquote | :button | :caption | :cell | :checkbox | :code | :columnheader | :combobox | :complementary | :contentinfo | :definition | :deletion | :dialog | :directory | :document | :emphasis | :feed | :figure | :form | :generic | :grid | :gridcell | :group | :heading | :img | :insertion | :link | :list | :listbox | :listitem | :log | :main | :marquee | :math | :meter | :menu | :menubar | :menuitem | :menuitemcheckbox | :menuitemradio | :navigation | :none | :note | :option | :paragraph | :presentation | :progressbar | :radio | :radiogroup | :region | :row | :rowgroup | :rowheader | :scrollbar | :search | :searchbox | :separator | :slider | :spinbutton | :status | :strong | :subscript | :superscript | :switch | :tab | :table | :tablist | :tabpanel | :term | :textbox | :time | :timer | :toolbar | :tooltip | :tree | :treegrid | :treeitem, not_to_have_role_options() ) :: :ok
Like not_to_have_role/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_screenshot( PlaywrightEx.Locator.t() | PlaywrightEx.Page.t(), not_to_have_screenshot_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_screenshot/2: expect(x).not.toHaveScreenshot(...) in JS.
Since Playwright 1.23.
Options
:path(String.t/0) - Required. The snapshot file. Must have a.pngor.webpextension, the screenshot is captured in the corresponding format. Both formats are lossless. A missing snapshot is written (see:update_snapshotsin the configuration ofPlaywrightEx.Expect); on failure the-actual,-diffand-previousimages are written next to it.:animations(:disabled|:allow) - When set to:disabled, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on their duration:- finite animations are fast-forwarded to completion, so they'll fire
transitionendevent. - infinite animations are canceled to initial state, and then played over after the screenshot.
Defaults to
:disabledthat disables animations.- finite animations are fast-forwarded to completion, so they'll fire
:caret(:hide|:initial) - When set to:hide, screenshot will hide text caret. When set to:initial, text caret behavior will not be changed. Defaults to:hide.:mask(list ofPlaywrightEx.Locator.t/0) - Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box#FF00FF(customized by:mask_color) that completely covers its bounding box. The mask is also applied to invisible elements, see Matching only visible elements to disable that.:mask_color(String.t/0) - Since Playwright 1.35. Specify the color of the overlay box for masked elements, in CSS color format. Default color is pink#FF00FF.:max_diff_pixel_ratio(number/0) - An acceptable ratio of pixels that are different to the total amount of pixels, between0and1. Default is configurable withconfig :playwright_ex, :expect(see the configuration inPlaywrightEx.Expect). Note that:thresholddefines which pixels are considered different.:max_diff_pixels(integer/0) - An acceptable amount of pixels that could be different. Default is configurable withconfig :playwright_ex, :expect(see the configuration inPlaywrightEx.Expect). Note that:thresholddefines which pixels are considered different.:omit_background(boolean/0) - Hides default white background and allows capturing screenshots with transparency. Not applicable tojpegimages. Defaults tofalse.:scale(:css|:device) - When set to:css, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will keep screenshots small. Using:deviceoption will produce a single pixel per each device pixel, so screenshots of high-dpi devices will be twice as large or even larger.Defaults to
:css.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:style_path(String.t/0| list ofString.t/0) - Since Playwright 1.41. File name containing the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make elements invisible or change their properties to help you creating repeatable screenshots. This stylesheet pierces the Shadow DOM and applies to the inner frames.:threshold(number/0) - An acceptable perceived color difference in the YIQ color space between the same pixel in compared images, between zero (strict) and one (lax), default is configurable withconfig :playwright_ex, :expect(see the configuration inPlaywrightEx.Expect). Defaults to0.2.:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.:clip(map/0) - An object which specifies clipping of the resulting image.:x- x-coordinate of top-left corner of clip area:y- y-coordinate of top-left corner of clip area:width- width of clipping area:height- height of clipping area
:full_page(boolean/0) - When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults tofalse.
@spec not_to_have_screenshot!( PlaywrightEx.Locator.t() | PlaywrightEx.Page.t(), not_to_have_screenshot_options() ) :: :ok
Like not_to_have_screenshot/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_text( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], not_to_have_text_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_text/3: expect(x).not.toHaveText(...) in JS.
Since Playwright 1.20.
Arguments
expected- Expected string or RegExp or a list of those.
Options
:ignore_case(boolean/0) - Since Playwright 1.23. Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression flag if specified.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.:use_inner_text(boolean/0) - Whether to useelement.innerTextinstead ofelement.textContentwhen retrieving DOM node text.
@spec not_to_have_text!( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], not_to_have_text_options() ) :: :ok
Like not_to_have_text/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_title( PlaywrightEx.Page.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_title_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_title/3: expect(x).not.toHaveTitle(...) in JS.
Since Playwright 1.20.
Arguments
title_or_reg_exp- Expected title or RegExp.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_title!( PlaywrightEx.Page.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_title_options() ) :: :ok
Like not_to_have_title/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_url( PlaywrightEx.Page.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | (String.t() -> boolean()), not_to_have_url_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_url/3: expect(x).not.toHaveURL(...) in JS.
Since Playwright 1.20.
Arguments
url- Expected URL string, RegExp, or predicate receivingURLto match. When:base_urlis provided via the context options and theurlargument is a string, the two values are merged via thenew URL()constructor and used for the comparison against the current browser URL.
Options
:ignore_case(boolean/0) - Since Playwright 1.44. Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression parameter if specified. A provided predicate ignores this flag.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_url!( PlaywrightEx.Page.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | (String.t() -> boolean()), not_to_have_url_options() ) :: :ok
Like not_to_have_url/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_value( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_value_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_value/3: expect(x).not.toHaveValue(...) in JS.
Since Playwright 1.20.
Arguments
value- Expected value.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_value!( PlaywrightEx.Locator.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), not_to_have_value_options() ) :: :ok
Like not_to_have_value/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_have_values( PlaywrightEx.Locator.t(), [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], not_to_have_values_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_have_values/3: expect(x).not.toHaveValues(...) in JS.
Since Playwright 1.23.
Arguments
values- Expected options currently selected.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_have_values!( PlaywrightEx.Locator.t(), [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], not_to_have_values_options() ) :: :ok
Like not_to_have_values/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec not_to_match_aria_snapshot( PlaywrightEx.Locator.t() | PlaywrightEx.Page.t(), String.t() | nil, not_to_match_aria_snapshot_options() ) :: :ok | {:error, PlaywrightEx.error()}
The opposite of to_match_aria_snapshot/3: expect(x).not.toMatchAriaSnapshot(...) in JS.
Since Playwright 1.49.
Options
The options may take the place of expected, which is then nil.
:path(String.t/0) - The snapshot file, in place ofexpected. Its content is the expected snapshot. A missing snapshot is written, unless:update_snapshotsis:noneor the matcher is negated. With:update_snapshotsset to:allit is always rewritten, with:changedwhen it differs (see the configuration ofPlaywrightEx.Expect).:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec not_to_match_aria_snapshot!( PlaywrightEx.Locator.t() | PlaywrightEx.Page.t(), String.t() | nil, not_to_match_aria_snapshot_options() ) :: :ok
Like not_to_match_aria_snapshot/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_be_attached( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_attached_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures that Locator points to an element that is connected to a Document or a ShadowRoot.
Usage
Page.get_by_text(page, "Hidden text") |> Expect.to_be_attached!()Since Playwright 1.33.
Options
:attached(boolean/0):signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_be_attached!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_attached_options() ) :: :ok
Like to_be_attached/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_be_checked( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_checked_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to a checked input.
Usage
locator = Page.get_by_label(page, "Subscribe to newsletter")
Expect.to_be_checked!(locator)Since Playwright 1.20.
Options
:checked(boolean/0) - Provides state to assert for. Asserts for input to be checked by default. This option can't be used when:indeterminateis set to true.:indeterminate(boolean/0) - Since Playwright 1.50. Asserts that the element is in the indeterminate (mixed) state. Only supported for checkboxes and radio buttons. This option can't be true when:checkedis provided.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_be_checked!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_checked_options() ) :: :ok
Like to_be_checked/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_be_disabled( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_disabled_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to a disabled element. Element is disabled if it has "disabled" attribute
or is disabled via 'aria-disabled'.
Note that only native control elements such as HTML button, input, select, textarea, option, optgroup
can be disabled by setting "disabled" attribute. "disabled" attribute on other elements is ignored
by the browser.
Usage
locator = Page.locator(page, "button.submit")
Expect.to_be_disabled!(locator)Since Playwright 1.20.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_be_disabled!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_disabled_options() ) :: :ok
Like to_be_disabled/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_be_editable( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_editable_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an editable element.
Usage
locator = Page.get_by_role(page, :textbox)
Expect.to_be_editable!(locator)Since Playwright 1.20.
Options
:editable(boolean/0) - Since Playwright 1.26.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_be_editable!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_editable_options() ) :: :ok
Like to_be_editable/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_be_empty( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_empty_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an empty editable element or to a DOM node that has no text.
Usage
locator = Page.locator(page, "div.warning")
Expect.to_be_empty!(locator)Since Playwright 1.20.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_be_empty!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_empty_options() ) :: :ok
Like to_be_empty/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_be_enabled( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_enabled_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an enabled element.
Usage
locator = Page.locator(page, "button.submit")
Expect.to_be_enabled!(locator)Since Playwright 1.20.
Options
:enabled(boolean/0) - Since Playwright 1.26.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_be_enabled!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_enabled_options() ) :: :ok
Like to_be_enabled/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_be_focused( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_focused_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to a focused DOM node.
Usage
locator = Page.get_by_role(page, :textbox)
Expect.to_be_focused!(locator)Since Playwright 1.20.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_be_focused!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_focused_options() ) :: :ok
Like to_be_focused/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_be_in_viewport( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_in_viewport_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element that intersects viewport, according to the intersection observer API.
Usage
locator = Page.get_by_role(page, :button)
# Make sure at least some part of element intersects viewport.
Expect.to_be_in_viewport!(locator)
# Make sure element is fully outside of viewport.
Expect.not_to_be_in_viewport!(locator)
# Make sure that at least half of the element intersects viewport.
Expect.to_be_in_viewport!(locator, ratio: 0.5)Since Playwright 1.31.
Options
:ratio(number/0) - The minimal ratio of the element to intersect viewport. If equals to0, then element should intersect viewport at any positive ratio. Defaults to0.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_be_in_viewport!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_in_viewport_options() ) :: :ok
Like to_be_in_viewport/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_be_ok(PlaywrightEx.APIResponse.t() | t(PlaywrightEx.APIResponse.t())) :: :ok | {:error, PlaywrightEx.error()}
Ensures the response status code is within 200..299 range.
Usage
Expect.to_be_ok!(response)Since Playwright 1.18.
@spec to_be_ok!(PlaywrightEx.APIResponse.t() | t(PlaywrightEx.APIResponse.t())) :: :ok
Like to_be_ok/1, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_be_visible( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_visible_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures that Locator points to an attached and visible DOM node.
To check that at least one element from the list is visible, use PlaywrightEx.Locator.first/1.
Usage
# A specific element is visible.
Page.get_by_text(page, "Welcome") |> Expect.to_be_visible!()
# At least one item in the list is visible.
Page.get_by_test_id(page, "todo-item") |> Locator.first() |> Expect.to_be_visible!()
# At least one of the two elements is visible, possibly both.
Page.get_by_role(page, :button, name: "Sign in")
|> Locator.or_(Page.get_by_role(page, :button, name: "Sign up"))
|> Locator.first()
|> Expect.to_be_visible!()Since Playwright 1.20.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.:visible(boolean/0) - Since Playwright 1.26.
@spec to_be_visible!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), to_be_visible_options() ) :: :ok
Like to_be_visible/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_contain_class( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | [String.t()], to_contain_class_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element with given CSS classes. All classes from the asserted value, separated by spaces, must be present in the Element.classList in any order.
Usage
<div class='middle selected row' id='component'></div>locator = Page.locator(page, "#component")
Expect.to_contain_class!(locator, "middle selected row")
Expect.to_contain_class!(locator, "selected")
Expect.to_contain_class!(locator, "row middle")When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected class lists. Each element's class attribute is matched against the corresponding class in the array:
<div class='list'>
<div class='component inactive'></div>
<div class='component active'></div>
<div class='component inactive'></div>
</div>locator = Page.locator(page, ".list > .component")
Expect.to_contain_class!(locator, ["inactive", "active", "inactive"])Since Playwright 1.52.
Arguments
expected- A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_contain_class!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | [String.t()], to_contain_class_options() ) :: :ok
Like to_contain_class/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_contain_text( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], to_contain_text_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element that contains the given text. All nested elements will be considered when computing the text content of the element. You can use regular expressions for the value as well.
Details
When expected parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual text and
in the expected string before matching. When regular expression is used, the actual text is matched as is.
Usage
locator = Page.locator(page, ".title")
Expect.to_contain_text!(locator, "substring")
Expect.to_contain_text!(locator, ~r/\d messages/)If you pass an array as an expected value, the expectations are:
- Locator resolves to a list of elements.
- Elements from a subset of this list contain text from the expected array, respectively.
- The matching subset of elements has the same order as the expected array.
- Each text value from the expected array is matched by some element from the list.
For example, consider the following list:
<ul>
<li>Item Text 1</li>
<li>Item Text 2</li>
<li>Item Text 3</li>
</ul>Let's see how we can use the assertion:
# ✓ Contains the right items in the right order
Page.locator(page, "ul > li") |> Expect.to_contain_text!(["Text 1", "Text 3"])
# ✖ Wrong order
{:error, _} = Page.locator(page, "ul > li") |> Expect.to_contain_text(["Text 3", "Text 2"])
# ✖ No item contains this text
{:error, _} = Page.locator(page, "ul > li") |> Expect.to_contain_text(["Some 33"])
# ✖ Locator points to the outer list element, not to the list items
# (in fact it passes: the list's text contains "Text 3")
:ok = Page.locator(page, "ul") |> Expect.to_contain_text(["Text 3"])Since Playwright 1.20.
Arguments
expected- Expected substring or RegExp or a list of those.
Options
:ignore_case(boolean/0) - Since Playwright 1.23. Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression flag if specified.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.:use_inner_text(boolean/0) - Whether to useelement.innerTextinstead ofelement.textContentwhen retrieving DOM node text.
@spec to_contain_text!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], to_contain_text_options() ) :: :ok
Like to_contain_text/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_accessible_description( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_accessible_description_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element with a given accessible description.
Usage
locator = Page.get_by_test_id(page, "save-button")
Expect.to_have_accessible_description!(locator, "Save results to disk")Since Playwright 1.44.
Arguments
description- Expected accessible description.
Options
:ignore_case(boolean/0) - Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression flag if specified.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_accessible_description!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_accessible_description_options() ) :: :ok
Like to_have_accessible_description/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_accessible_error_message( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_accessible_error_message_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element with a given aria errormessage.
Usage
locator = Page.get_by_test_id(page, "username-input")
Expect.to_have_accessible_error_message!(locator, "Username is required.")Since Playwright 1.50.
Arguments
error_message- Expected accessible error message.
Options
:ignore_case(boolean/0) - Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression flag if specified.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_accessible_error_message!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_accessible_error_message_options() ) :: :ok
Like to_have_accessible_error_message/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_accessible_name( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_accessible_name_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element with a given accessible name.
Usage
locator = Page.get_by_test_id(page, "save-button")
Expect.to_have_accessible_name!(locator, "Save to disk")Since Playwright 1.44.
Arguments
name- Expected accessible name.
Options
:ignore_case(boolean/0) - Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression flag if specified.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_accessible_name!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_accessible_name_options() ) :: :ok
Like to_have_accessible_name/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_attribute( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | nil, to_have_attribute_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element with given attribute.
Usage
locator = Page.locator(page, "input")
Expect.to_have_attribute!(locator, "type", "text")locator = Page.locator(page, "input")
# Assert attribute existence.
Expect.to_have_attribute!(locator, "disabled")
Expect.not_to_have_attribute!(locator, "open")Since Playwright 1.20.
Arguments
name- Attribute name.value- Expected attribute value.
Options
The options may take the place of value, which is then nil.
:ignore_case(boolean/0) - Since Playwright 1.40. Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression flag if specified.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_attribute!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | nil, to_have_attribute_options() ) :: :ok
Like to_have_attribute/4, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_class( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], to_have_class_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element with given CSS classes. When a string is provided, it must fully match the element's class attribute. To match individual classes use PlaywrightEx.Expect.to_contain_class/3.
Usage
<div class='middle selected row' id='component'></div>locator = Page.locator(page, "#component")
Expect.to_have_class!(locator, "middle selected row")
Expect.to_have_class!(locator, ~r/(^|\s)selected(\s|$)/)When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected class values. Each element's class attribute is matched against the corresponding string or regular expression in the array:
locator = Page.locator(page, ".list > .component")
Expect.to_have_class!(locator, ["component", "component selected", "component"])Since Playwright 1.20.
Arguments
expected- Expected class or RegExp or a list of those.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_class!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], to_have_class_options() ) :: :ok
Like to_have_class/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_count( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), integer(), to_have_count_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator resolves to an exact number of DOM nodes.
Usage
list = Page.locator(page, "list > .component")
Expect.to_have_count!(list, 3)Since Playwright 1.20.
Arguments
count- Expected count.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_count!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), integer(), to_have_count_options() ) :: :ok
Like to_have_count/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_css( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_css_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator resolves to an element with the given computed CSS style.
Usage
locator = Page.get_by_role(page, :button)
Expect.to_have_css!(locator, "display", "flex")Since Playwright 1.20.
Arguments
name- CSS property name.value- CSS property value.
Options
:pseudo(:before|:after) - Since Playwright 1.60. Pseudo-element to read computed styles from.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_css!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t(), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_css_options() ) :: :ok
Like to_have_css/4, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_id( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_id_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element with the given DOM Node ID.
Usage
locator = Page.get_by_role(page, :textbox)
Expect.to_have_id!(locator, "lastname")Since Playwright 1.20.
Arguments
id- Element id.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_id!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_id_options() ) :: :ok
Like to_have_id/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_js_property( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t(), term(), to_have_js_property_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element with given JavaScript property. Note that this property can be
of a primitive type as well as a plain serializable JavaScript object.
Usage
locator = Page.locator(page, ".component")
Expect.to_have_js_property!(locator, "loaded", true)Since Playwright 1.20.
Arguments
name- Property name.value- Property value.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_js_property!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t(), term(), to_have_js_property_options() ) :: :ok
Like to_have_js_property/4, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_role( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), :alert | :alertdialog | :application | :article | :banner | :blockquote | :button | :caption | :cell | :checkbox | :code | :columnheader | :combobox | :complementary | :contentinfo | :definition | :deletion | :dialog | :directory | :document | :emphasis | :feed | :figure | :form | :generic | :grid | :gridcell | :group | :heading | :img | :insertion | :link | :list | :listbox | :listitem | :log | :main | :marquee | :math | :meter | :menu | :menubar | :menuitem | :menuitemcheckbox | :menuitemradio | :navigation | :none | :note | :option | :paragraph | :presentation | :progressbar | :radio | :radiogroup | :region | :row | :rowgroup | :rowheader | :scrollbar | :search | :searchbox | :separator | :slider | :spinbutton | :status | :strong | :subscript | :superscript | :switch | :tab | :table | :tablist | :tabpanel | :term | :textbox | :time | :timer | :toolbar | :tooltip | :tree | :treegrid | :treeitem, to_have_role_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element with a given ARIA role.
Note that role is matched as a string, disregarding the ARIA role hierarchy. For example, asserting a superclass role :checkbox on an element with a subclass role :switch will fail.
Usage
locator = Page.get_by_test_id(page, "save-button")
Expect.to_have_role!(locator, :button)Since Playwright 1.44.
Arguments
role- Required aria role.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_role!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), :alert | :alertdialog | :application | :article | :banner | :blockquote | :button | :caption | :cell | :checkbox | :code | :columnheader | :combobox | :complementary | :contentinfo | :definition | :deletion | :dialog | :directory | :document | :emphasis | :feed | :figure | :form | :generic | :grid | :gridcell | :group | :heading | :img | :insertion | :link | :list | :listbox | :listitem | :log | :main | :marquee | :math | :meter | :menu | :menubar | :menuitem | :menuitemcheckbox | :menuitemradio | :navigation | :none | :note | :option | :paragraph | :presentation | :progressbar | :radio | :radiogroup | :region | :row | :rowgroup | :rowheader | :scrollbar | :search | :searchbox | :separator | :slider | :spinbutton | :status | :strong | :subscript | :superscript | :switch | :tab | :table | :tablist | :tabpanel | :term | :textbox | :time | :timer | :toolbar | :tooltip | :tree | :treegrid | :treeitem, to_have_role_options() ) :: :ok
Like to_have_role/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_screenshot( PlaywrightEx.Locator.t() | PlaywrightEx.Page.t() | t(PlaywrightEx.Locator.t() | PlaywrightEx.Page.t()), to_have_screenshot_options() ) :: :ok | {:error, PlaywrightEx.error()}
This function will wait until two consecutive locator screenshots yield the same result, and then compare the last screenshot with the expectation.
Usage
Expect.to_have_screenshot!(page, path: "test/snapshots/image.png")Since Playwright 1.23.
Options
:path(String.t/0) - Required. The snapshot file. Must have a.pngor.webpextension, the screenshot is captured in the corresponding format. Both formats are lossless. A missing snapshot is written (see:update_snapshotsin the configuration ofPlaywrightEx.Expect); on failure the-actual,-diffand-previousimages are written next to it.:animations(:disabled|:allow) - When set to:disabled, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on their duration:- finite animations are fast-forwarded to completion, so they'll fire
transitionendevent. - infinite animations are canceled to initial state, and then played over after the screenshot.
Defaults to
:disabledthat disables animations.- finite animations are fast-forwarded to completion, so they'll fire
:caret(:hide|:initial) - When set to:hide, screenshot will hide text caret. When set to:initial, text caret behavior will not be changed. Defaults to:hide.:mask(list ofPlaywrightEx.Locator.t/0) - Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box#FF00FF(customized by:mask_color) that completely covers its bounding box. The mask is also applied to invisible elements, see Matching only visible elements to disable that.:mask_color(String.t/0) - Since Playwright 1.35. Specify the color of the overlay box for masked elements, in CSS color format. Default color is pink#FF00FF.:max_diff_pixel_ratio(number/0) - An acceptable ratio of pixels that are different to the total amount of pixels, between0and1. Default is configurable withconfig :playwright_ex, :expect(see the configuration inPlaywrightEx.Expect). Note that:thresholddefines which pixels are considered different.:max_diff_pixels(integer/0) - An acceptable amount of pixels that could be different. Default is configurable withconfig :playwright_ex, :expect(see the configuration inPlaywrightEx.Expect). Note that:thresholddefines which pixels are considered different.:omit_background(boolean/0) - Hides default white background and allows capturing screenshots with transparency. Not applicable tojpegimages. Defaults tofalse.:scale(:css|:device) - When set to:css, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will keep screenshots small. Using:deviceoption will produce a single pixel per each device pixel, so screenshots of high-dpi devices will be twice as large or even larger.Defaults to
:css.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:style_path(String.t/0| list ofString.t/0) - Since Playwright 1.41. File name containing the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make elements invisible or change their properties to help you creating repeatable screenshots. This stylesheet pierces the Shadow DOM and applies to the inner frames.:threshold(number/0) - An acceptable perceived color difference in the YIQ color space between the same pixel in compared images, between zero (strict) and one (lax), default is configurable withconfig :playwright_ex, :expect(see the configuration inPlaywrightEx.Expect). Defaults to0.2.:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.:clip(map/0) - An object which specifies clipping of the resulting image.:x- x-coordinate of top-left corner of clip area:y- y-coordinate of top-left corner of clip area:width- width of clipping area:height- height of clipping area
:full_page(boolean/0) - When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults tofalse.
@spec to_have_screenshot!( PlaywrightEx.Locator.t() | PlaywrightEx.Page.t() | t(PlaywrightEx.Locator.t() | PlaywrightEx.Page.t()), to_have_screenshot_options() ) :: :ok
Like to_have_screenshot/2, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_text( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], to_have_text_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element with the given text. All nested elements will be considered when computing the text content of the element. You can use regular expressions for the value as well.
Details
When expected parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual text and
in the expected string before matching. When regular expression is used, the actual text is matched as is.
Usage
locator = Page.locator(page, ".title")
Expect.to_have_text!(locator, ~r/Welcome, Test User/)
Expect.to_have_text!(locator, ~r/Welcome, .*/)If you pass an array as an expected value, the expectations are:
- Locator resolves to a list of elements.
- The number of elements equals the number of expected values in the array.
- Elements from the list have text matching expected array values, one by one, in order.
For example, consider the following list:
<ul>
<li>Text 1</li>
<li>Text 2</li>
<li>Text 3</li>
</ul>Let's see how we can use the assertion:
# ✓ Has the right items in the right order
Page.locator(page, "ul > li") |> Expect.to_have_text!(["Text 1", "Text 2", "Text 3"])
# ✖ Wrong order
{:error, _} = Page.locator(page, "ul > li") |> Expect.to_have_text(["Text 3", "Text 2", "Text 1"])
# ✖ Last item does not match
{:error, _} = Page.locator(page, "ul > li") |> Expect.to_have_text(["Text 1", "Text 2", "Text"])
# ✖ Locator points to the outer list element, not to the list items
{:error, _} = Page.locator(page, "ul") |> Expect.to_have_text(["Text 1", "Text 2", "Text 3"])Since Playwright 1.20.
Arguments
expected- Expected string or RegExp or a list of those.
Options
:ignore_case(boolean/0) - Since Playwright 1.23. Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression flag if specified.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.:use_inner_text(boolean/0) - Whether to useelement.innerTextinstead ofelement.textContentwhen retrieving DOM node text.
@spec to_have_text!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], to_have_text_options() ) :: :ok
Like to_have_text/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_title( PlaywrightEx.Page.t() | t(PlaywrightEx.Page.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_title_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the page has the given title.
Usage
Expect.to_have_title!(page, ~r/.*checkout/)Since Playwright 1.20.
Arguments
title_or_reg_exp- Expected title or RegExp.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_title!( PlaywrightEx.Page.t() | t(PlaywrightEx.Page.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_title_options() ) :: :ok
Like to_have_title/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_url( PlaywrightEx.Page.t() | t(PlaywrightEx.Page.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | (String.t() -> boolean()), to_have_url_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the page is navigated to the given URL.
Usage
# Check for the page URL to be 'https://playwright.dev/docs/intro' (including query string)
Expect.to_have_url!(page, "https://playwright.dev/docs/intro")
# Check for the page URL to contain 'doc', followed by an optional 's', followed by '/'
Expect.to_have_url!(page, ~r/docs?\//)
# Check for the page URL to match the URL pattern (Elixir has no URLPattern: a predicate)
Expect.to_have_url!(page, &String.starts_with?(URI.parse(&1).path, "/docs/"))
# Check for the predicate to be satisfied
# For example: verify query strings
Expect.to_have_url!(page, fn url ->
params = URI.decode_query(URI.parse(url).query || "")
Map.has_key?(params, "search") and Map.has_key?(params, "options") and params["id"] == "5"
end)Since Playwright 1.20.
Arguments
url- Expected URL string, RegExp, or predicate receivingURLto match. When:base_urlis provided via the context options and theurlargument is a string, the two values are merged via thenew URL()constructor and used for the comparison against the current browser URL.
Options
:ignore_case(boolean/0) - Since Playwright 1.44. Whether to perform case-insensitive match.:ignore_caseoption takes precedence over the corresponding regular expression parameter if specified. A provided predicate ignores this flag.:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_url!( PlaywrightEx.Page.t() | t(PlaywrightEx.Page.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t() | (String.t() -> boolean()), to_have_url_options() ) :: :ok
Like to_have_url/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_value( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_value_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to an element with the given input value. You can use regular expressions for the value as well.
Usage
locator = Page.locator(page, "input[type=number]")
Expect.to_have_value!(locator, ~r/[0-9]/)Since Playwright 1.20.
Arguments
value- Expected value.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_value!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), String.t() | Regex.t() | PlaywrightEx.RegExp.t(), to_have_value_options() ) :: :ok
Like to_have_value/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_have_values( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], to_have_values_options() ) :: :ok | {:error, PlaywrightEx.error()}
Ensures the Locator points to multi-select/combobox (i.e. a select with the multiple attribute) and the specified values are selected.
Usage
For example, given the following element:
<select id="favorite-colors" multiple>
<option value="R">Red</option>
<option value="G">Green</option>
<option value="B">Blue</option>
</select>locator = Page.locator(page, "id=favorite-colors")
Locator.select_option!(locator, ["R", "G"])
Expect.to_have_values!(locator, [~r/R/, ~r/G/])Since Playwright 1.23.
Arguments
values- Expected options currently selected.
Options
:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_have_values!( PlaywrightEx.Locator.t() | t(PlaywrightEx.Locator.t()), [String.t() | Regex.t() | PlaywrightEx.RegExp.t()], to_have_values_options() ) :: :ok
Like to_have_values/3, but raises PlaywrightEx.ExpectError when the expectation is not met.
@spec to_match_aria_snapshot( PlaywrightEx.Locator.t() | PlaywrightEx.Page.t() | t(PlaywrightEx.Locator.t() | PlaywrightEx.Page.t()), String.t() | nil, to_match_aria_snapshot_options() ) :: :ok | {:error, PlaywrightEx.error()}
Asserts that the target element matches the given accessibility snapshot.
Usage
Page.goto!(page, "https://demo.playwright.dev/todomvc/")
Page.locator(page, "body")
|> Expect.to_match_aria_snapshot!("""
- heading "todos"
- textbox "What needs to be done?"
""")Expect.to_match_aria_snapshot!(page, path: "test/snapshots/body.aria.yml")Since Playwright 1.49.
Options
The options may take the place of expected, which is then nil.
:path(String.t/0) - The snapshot file, in place ofexpected. Its content is the expected snapshot. A missing snapshot is written, unless:update_snapshotsis:noneor the matcher is negated. With:update_snapshotsset to:allit is always rewritten, with:changedwhen it differs (see the configuration ofPlaywrightEx.Expect).:signal(PlaywrightEx.AbortSignal.t/0) - Since Playwright 1.62. An optionalAbortSignalthat can cancel the assertion. Aborting the signal fails the assertion like a timeout: if the signal is aborted while the assertion is retrying, or is already aborted before the assertion starts, the assertion fails without retrying further.In Elixir, a
PlaywrightEx.AbortSignal(PlaywrightEx.AbortController.signal/1).:timeout(number/0|:infinity) - Time to retry the assertion for in milliseconds,0for no timeout. Defaults to:timeoutinconfig :playwright_ex, :expect(5000if not set, see the configuration inPlaywrightEx.Expect).In Elixir,
:infinityis the same as0: no timeout.
@spec to_match_aria_snapshot!( PlaywrightEx.Locator.t() | PlaywrightEx.Page.t() | t(PlaywrightEx.Locator.t() | PlaywrightEx.Page.t()), String.t() | nil, to_match_aria_snapshot_options() ) :: :ok
Like to_match_aria_snapshot/3, but raises PlaywrightEx.ExpectError when the expectation is not met.