Playwright Native Test

toBeChecked
Docs

Ensures the Locator points to a checked input.

toBeDisabled
Docs

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.

link
toBeEditable
Docs

Ensures the Locator points to an editable element.

toBeEmpty
Docs

Ensures the Locator points to an empty editable element or to a DOM node that has no text.

toBeEnabled
Docs

Ensures the Locator points to an enabled element.

toBeFocused
Docs

Ensures the Locator points to a focused DOM node.

toBeHidden
Docs

Ensures that Locator either does not resolve to any DOM node, or resolves to a non-visible one.

Visibility Hidden Example
Display None Example
toBeVisible
Docs

Ensures that Locator points to an attached and visible DOM node.

Html Element
Zero Opacity Example
Hidden Parent Example
Visible Example
Title of hidden textHidden Details Example
Title of visible text
Visible Details Example
toContainText
Docs

Ensures the Locator points to an element that contains the given text. You can use regular expressions for the value as well. If you pass an array as an expected value, the expectations are:

  1. Locator resolves to a list of elements.
  2. Elements from a subset of this list contain text from the expected array, respectively.
  3. The matching subset of elements has the same order as the expected array.
  4. Each text value from the expected array is matched by some element from the list.
to Contain Text
  • Item Text 1
  • Item Text 2
  • Item Text 3
toHaveAttribute
Docs

Ensures the Locator points to an element with given attribute.

toHaveClass
Docs

Ensures the Locator points to an element with given CSS classes. This needs to be a full match or using a relaxed regular expression.

toHaveCss
Docs

Ensures the Locator resolves to an element with the given computed CSS style.

toHaveId
Docs

Ensures the Locator points to an element with the given DOM Node ID.

toHaveText
Docs

Ensures the Locator points to an element with the given text. If you pass an array as an expected value, the expectations are:

  1. Locator resolves to a list of elements.
  2. The number of elements equals the number of expected values in the array.
  3. Elements from the list have text matching expected array values, one by one, in order.
Text Content
  • Text 1
  • Text 2
  • Text 3
toHaveValue
Docs

Ensures the Locator points to an element with the given input value. You can use regular expressions for the value as well.

toHaveValues
Docs

Ensures the Locator points to multi-select/combobox (i.e. a select with the multiple attribute) and the specified values are selected.

toHaveTitle
Docs

Ensures the page has the given title.

toHaveURL
Docs

Ensures the page is navigated to the given URL.