Skip to content

Assertions Reference

open Scriptorium.Nib.Browser

All DOM assertions wrap Playwright’s LocatorAssertions (expect(locator).*). They operate on a Locator subject.

AssertionPlaywright equivalent
toBeVisibleexpect(l).toBeVisible()
beHiddenexpect(l).toBeHidden()
beEnabledexpect(l).toBeEnabled()
beDisabledexpect(l).toBeDisabled()
beFocusedexpect(l).toBeFocused()
beCheckedexpect(l).toBeChecked()
beEmptyexpect(l).toBeEmpty()
beEditableexpect(l).toBeEditable()
AssertionDescription
containText (expected: string)The element contains expected anywhere in its text
haveText (expected: string)The element’s full text matches expected exactly
AssertionDescription
haveValue (expected: string)The input’s value equals expected
haveAttribute (name: string) (value: string)The element has the given attribute with the given value
haveClass (expected: string)The element’s class list contains exactly the classes in expected
containClass (expected: string)The element’s class list contains all classes in expected
haveCSS (name: string) (value: string)The element has the given computed CSS property
haveCount (expected: int)The locator resolves to exactly expected DOM nodes

Use not' (or not_) to invert any DOM assertion:

promise {
do! assertLocator (page.locator "button") (
not' beDisabled >>. toBeVisible
)
}