lmwebtest authoring skill

Guidance for authoring, running, and verifying browser automation and web integration test scripts with the lmwebtest and lmwebtest playwright hosts.

Purpose

Help write deterministic lmscript browser automation and integration test programs using either the concise Web DSL (context web: Web and context report: Report) or the full Playwright lmcode host (cli="lmwebtest playwright", context pw: Playwright), as well as standalone CLI page checks and screenshots.

When to use it

Use lmwebtest when a target page requires JavaScript execution, client-rendered DOM waits, interactive clicks, form fills, multipart file uploads, downloads, popups, dialogs, request routing, or visual screenshot capture that static HTTP fetching with lmcurl cannot satisfy alone.

Install

Install via lmscript with lmscript install github:lmctl-ai/lmwebtest (or download a single-file platform executable from GitHub Releases) and install the Playwright Chromium browser binary once with npx playwright install chromium. In _lmcode_ blocks, declare cli="lmwebtest" install="github:lmctl-ai/lmwebtest@latest" for the Web DSL or cli="lmwebtest playwright" for the full Playwright API.

Commands

lmscript install github:lmctl-ai/lmwebtest
npx playwright install chromium
lmwebtest --version
lmwebtest --lmcode-schema --json
lmwebtest --lmcode-signatures
lmwebtest playwright --lmcode-schema --json
lmwebtest playwright --lmcode-signatures
lmwebtest test http://127.0.0.1:3000 --status 200 --title "File Explorer" --selector "#file-table"
lmwebtest screenshot http://127.0.0.1:3000 --out screenshots/demo.png

Inputs and outputs

Safety rules

Worked examples

# 1. Web DSL: wait for client-rendered table rows and hand rendered HTML to lmhtml
let acquire = _lmcode_ cli="lmwebtest" install="github:lmctl-ai/lmwebtest@latest";
let page = web.navigate("https://platform.kimi.ai/docs/pricing/batch");
page.wait_for("table tbody tr", 15000);
if (page.count("table tbody tr") == 0) {
  report.add("empty_table", "table tbody tr", 1, "Expected client-rendered pricing rows");
  report.fail_if_any();
}
page.save_html("build/rendered.html");
web.close();
end _lmcode_
let r1 = run_lmcode(acquire);
require(r1.ok, "browser acquisition failed");

# 2. Full Playwright host: upload in-memory and local files and inspect response
let upload = _lmcode_ cli="lmwebtest playwright";
let b = pw.launch("chromium");
let p = b.new_page();
p.goto(pw.env("LMMOCK_URL") + "/upload");
p.set_input_files("#file", "[{\"name\":\"a.txt\",\"mimeType\":\"text/plain\",\"text\":\"alpha\"}]");
let resp = p.click_response("#send", "**/upload");
$return.status = resp.status();
b.close();
end _lmcode_

Errors and exit codes

In CLI mode (test, screenshot, run, batch, init), exit 0 means all checks passed, exit 1 means a page check failed (unexpected HTTP status, console error, uncaught page error, failed network request, HTTP 4xx/5xx resource, missing visible selector, or broken image), and exit 2 means invalid CLI arguments. In lmcode host mode (--lmcode and playwright --lmcode), exit 0 is success, exit 2 is CLI/usage error, exit 3 is bytecode load or runtime failure (including missing Chromium binaries or report.fail_if_any()), and exit 4 is application failure.

How to verify

  1. Run lmwebtest --version, lmwebtest --lmcode-signatures, and lmwebtest playwright --lmcode-signatures to confirm the host and embedded schemas are ready.
  2. Run ./demo-app/run.sh and ./upload-app/run.sh from a checkout to verify offline browser navigation, session-cookie auth, multipart file uploads, and lmhtml DOM extraction against lmmock.
  3. Inspect saved HTML snapshots, screenshots, and JSON report outputs to confirm zero console errors, broken images, or missing selectors.