一键导入
bunwright
Use this skill when you need lightweight, scriptable browser automation in Bun based on `Bun.WebView`.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use this skill when you need lightweight, scriptable browser automation in Bun based on `Bun.WebView`.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | bunwright |
| description | Use this skill when you need lightweight, scriptable browser automation in Bun based on `Bun.WebView`. |
| metadata | {"mintlify-proj":"bun","version":"2.0"} |
Use this skill when you need lightweight, scriptable browser automation in Bun based on Bun.WebView, especially when you want to:
bunwright package in another Bun project via bun link or bun addThis repository exposes:
import { browser } from "bunwright" — a singleton wrapping one Bun.WebViewbunx bunwright <script.ts> — loads .env.local/.env, imports the script, runs its default export// my-flow.ts
import { browser } from "bunwright";
const page = await browser.newPage();
await page
.navigate("https://example.com/login")
.type("label:Username", process.env.APP_USER!)
.type("label:Password", process.env.APP_PASSWORD!)
.click("role:button[name='Login']")
.waitForURL("**/dashboard")
.screenshot("./generated/dashboard.png");
await browser.close();
bunx bunwright my-flow.ts
retryTimeout (default 10s)browser lazily creates one shared Bun.WebView; contexts and pages all wrap it (no isolation)evaluate() calls are serialized per WebView, so Promise.all over page/locator reads is safebrowser.close() closes the WebView and kills any externally-spawned ChromePage, Locator, and ElementHandle methods chain without intermediate awaits — chains are lazy queues flushed by await:
instanceof TimeoutError preserved)count(), evaluate(), exists()).all() resolves with every step's result in call orderconst [, , title] = await page
.navigate("https://example.com")
.click("role:button")
.evaluate(() => document.title)
.all();
waitForURL accepts URL globs (**/dashboard) or a RegExp; globs match the full URL.
Prefixed strings; unprefixed strings are treated as CSS:
| Prefix | Example | Matches by |
|---|---|---|
css: | css:button[type=submit] | CSS selector |
role: | role:button[name='Login'] | ARIA role (and name) |
label: | label:Username | Associated <label> text |
text: | text:Sign in | Visible text content |
xpath: | xpath://button[1] | XPath expression |
Via bunwright.config.{ts,js,mjs} in cwd, or defineConfig() in code. Resolution: defaults ← config file ← defineConfig.
| Field | Type | Notes |
|---|---|---|
backend | "chrome" | "webkit" | { type: "chrome", path?, argv? } | Defaults to "chrome" |
width | number | Defaults to 1280 |
height | number | Defaults to 800 |
url | string | Initial URL |
console | boolean | Forward page console output |
dataStore | "ephemeral" | string | Directory path for persistent state |
retryTimeout | number | Default 10000 ms |
headless | boolean | Defaults to true on Windows, false elsewhere |
Chainable (return this): navigate, back, forward, reload, click, dblClick, type, press, scroll, scrollTo, resize, screenshot, expect, check, waitForLoadState.
Non-chainable: evaluate(fn), locator(sel), $/$$ (ElementHandle snapshots), waitForSelector, waitForURL, exists, waitFor, waitForTimeout, cdp(method, params).
backend: "chrome" for cross-platform uselabel:/role: selectors over brittle CSS for form interactionsevaluate an arrow function; it is serialized and run in the pagewaitForTimeout when waitForSelector/waitForURL/waitForLoadState can express the condition.env/.env.local; the CLI loads them before the script runs and never overrides existing env varsBun.WebView's built-in Chrome spawn fails on Windows. bunwright launches Chrome itself with --remote-debugging-port and connects via webSocketDebuggerUrl. In this mode backend.path/backend.argv are ignored; executable resolution is BUN_CHROME_PATH → config.backend.path → common install locations. BUNWRIGHT_DEBUG=1 logs the spawned port.
packages/app/src/bunwright.tspackages/app/src/dsl/index.tspackages/app/docs/api-reference.md (auto-generated; regenerate with bun run docs)packages/app/examples/*.tsUse those files as the source of truth when adapting bunwright in another project.