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.
BrowserTest
Section titled “BrowserTest”| Helper | Description |
|---|---|
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.Testopen type Scriptorium.Quill.Runneropen type Scriptorium.Nib.Browser.UserEventsopen 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" ) } )
]) ]Debug mode — dtestPage
Section titled “Debug mode — dtestPage”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 })User events
Section titled “User events”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"}| Method | Description |
|---|---|
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) |