Playwright
Fluent browser automation and testing for BoxLang, powered by Microsoft Playwright: drive real browsers, test web apps and APIs, and render HTML to PDFs and images.
The bx-playwright module brings Microsoft Playwright to BoxLang with a fluent, BoxLang native API. Drive Chromium, Firefox and WebKit, test web applications end to end, mock the network, test APIs, and render HTML to PDFs or images.
✨ Features
Fluent DSL through the
playwright()BIF: smart selectors, chainable actions, and web-first assertions that wait for the pageTwo assertion styles: inline (
assertSee(),assertPathIs()) andexpect()(toHaveText(),toBeVisible())Profiles for browsers, screens, devices and modes (
mobile,dark,ci,debug) plus your own in module settingsRendering:
bx:playwrightRenderandrender()turn HTML into PDF, PNG, JPEG or WebP with a real browserNetwork and APIs: request interception and mocking, and
request()for API testingQuality checks: visual regression with diff images, console errors, smoke tests, and axe-core accessibility checks
Page objects, components and macros to keep tests readable
Built for AI agents: accessibility snapshots with element refs, browser tools for BoxLang AI agents, and
help()on every objectbxplaywrightCLI with bash completions: install browsers,doctor,codegenthat records BoxLang code, screenshots, PDFs and Playwright MCP
📦 Installation
Two distributions are published to ForgeBox:
bx-playwright
Small (about 4 MB)
Uses a system Node.js 20+, or downloads one with bxplaywright install
bx-playwright-full
Large (about 200 MB)
Bundled for every platform, works offline
⚡ Quick Start
browse() starts the browser, runs your closure, and cleans everything up, even when an assertion fails. Selectors can be CSS, @testId (for data-testid), or the visible text or label a user sees, as in fill( "Email" ) and click( "Sign in" ).
🎭 Profiles
Run bxplaywright profiles to list them. Add your own under modules.bxplaywright.settings.profiles in boxlang.json, or override settings with BX_PLAYWRIGHT_* environment variables.
🖨️ Rendering
✅ Testing and Quality
bx-playwright works in any test framework, including TestBox:
A failed assertScreenshotMatches() writes the actual image and a diff image with the changed pixels in red. The ci profile keeps screenshots, traces and videos of failed tests.
🤖 AI Agents
See Browser Agents to give a BoxLang AI agent a browser, and Build an App End to End to let a coding agent verify the application it builds.
🔗 Resources
Documentation: bxplaywright.boxlang.io
Agent skills:
npx skills add ortus-boxlang/skills/boxlang-modules/bx-playwright
Last updated
Was this helpful?
