For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

This page is a summary. The complete documentation lives at bxplaywright.boxlang.io, also available as llms.txt for AI agents.

✨ Features

  • Fluent DSL through the playwright() BIF: smart selectors, chainable actions, and web-first assertions that wait for the page

  • Two assertion styles: inline (assertSee(), assertPathIs()) and expect() (toHaveText(), toBeVisible())

  • Profiles for browsers, screens, devices and modes (mobile, dark, ci, debug) plus your own in module settings

  • Rendering: bx:playwrightRender and render() turn HTML into PDF, PNG, JPEG or WebP with a real browser

  • Network and APIs: request interception and mocking, and request() for API testing

  • Quality 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 object

  • bxplaywright CLI with bash completions: install browsers, doctor, codegen that records BoxLang code, screenshots, PDFs and Playwright MCP

📦 Installation

Two distributions are published to ForgeBox:

Module
Size
Node.js

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

Last updated

Was this helpful?