Skip to content

Browser tests

Scriptorium.Nib.Browser provides test helpers that integrate with Scriptorium.Quill’s test DSL. They automatically create a headless Chromium browser, run the body, then close the browser and page.

HelperDescription
BrowserTest.testPage(name, body)Normal headless test
BrowserTest.xtestPage(name, body)Pending (skipped) test
BrowserTest.ftestPage(name, body)Focused test
BrowserTest.dtestPage(name, body)Debug mode: headed, auto-paused, focused, no timeout
open type Scriptorium.Quill.Test
open type Scriptorium.Quill.Runner
open type Scriptorium.Nib.Browser.UserEvents
open type Scriptorium.Nib.Browser.BrowserTest
[<EntryPoint>]
let main _ =
runTests [
testList ("Home page", [
testPage ("shows the title", fun page ->
promise {
do! page.goto "http://localhost:3000"
do! assertLocator (page.locator "h1") (
toBeVisible >>. containText "Welcome"
)
}
)
testPage ("login button is enabled", fun page ->
promise {
do! page.goto "http://localhost:3000/login"
do! assertLocator (page.locator "button[type=submit]") (
toBeVisible >>. beEnabled >>. containText "Sign in"
)
}
)
])
]

BrowserTest.dtestPage opens a visible browser window, pauses before running the body (so you can inspect the initial state), sets no timeout, and marks the test as focused. Use it while writing or debugging a test, then switch back to testPage before committing.

BrowserTest.dtestPage ("debug login flow", fun page ->
promise {
do! page.goto "http://localhost:3000/login"
// Playwright Inspector opens here — step through manually
do! assertLocator (page.locator "button") toBeVisible
}
)

UserEvents provides typed wrappers for common Playwright interactions:

open type Scriptorium.Nib.Browser.UserEvents
promise {
do! click (page.locator "button[type=submit]")
do! fill (page.locator "input[name=email]") "alice@example.com"
do! press (page.locator "input") "Enter"
do! check (page.locator "input[type=checkbox]")
do! selectOption (page.locator "select") "option-value"
}
MethodDescription
UserEvents.click(locator)Click the element
UserEvents.focus(locator)Focus the element
UserEvents.blur(locator)Remove focus from the element
UserEvents.hover(locator)Hover over the element
UserEvents.check(locator)Check a checkbox or radio
UserEvents.uncheck(locator)Uncheck a checkbox or radio
UserEvents.fill(locator, value)Fill an input field
UserEvents.press(locator, key)Press a key combination
UserEvents.selectOption(locator, value)Select an option in a <select>
UserEvents.highlight(locator)Highlight the element (debugging only)