一键导入
playwright-automation
Browser automation templates for pi-scheduler using Playwright
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Browser automation templates for pi-scheduler using Playwright
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | playwright-automation |
| description | Browser automation templates for pi-scheduler using Playwright |
| version | 1.0.0 |
pi-scheduler includes three built-in templates for browser automation via Playwright. These templates execute as JavaScript scripts in a child_process, keeping pi-scheduler-core zero-dependency.
Install Playwright in your project directory (the cwd you set on the automation):
npm install playwright
npx playwright install chromium
web-screenshotNavigates to a URL and saves a screenshot.png in the automation's cwd.
scheduler.instantiateTemplate('web-screenshot', {
name: 'Dashboard screenshot',
cwd: 'D:/repos/myproject',
params: { url: 'http://localhost:3000' },
});
Params: url — target URL (no query strings; use simple URLs like http://host:port/path).
url-health-checkLoads a URL with a real browser and exits with code 1 if HTTP status ≥ 400. Useful for SPAs or pages behind auth that need JavaScript to render.
scheduler.instantiateTemplate('url-health-check', {
name: 'API health',
intervalMinutes: 5,
cwd: 'D:/repos/myproject',
params: { url: 'http://localhost:8080/health' },
});
Params: url — endpoint to check.
login-flowSubmits a login form and reports the resulting page title. Useful for verifying an auth flow is still working.
scheduler.instantiateTemplate('login-flow', {
name: 'Auth smoke check',
intervalMinutes: 30,
cwd: 'D:/repos/myproject',
params: { url: 'https://myapp.internal/login' },
});
Params: url — login page URL.
Env vars: PW_USERNAME, PW_PASSWORD — credentials (never put secrets in the params object).
The login-flow template uses heuristic selectors (
[name="username"],[type="submit"]). Copy the script to a custom template and adjust selectors for your specific app.
Register your own template at runtime:
scheduler.registerTemplate({
id: 'my-playwright-task',
name: 'My browser task',
description: 'Custom Playwright automation.',
defaultInterval: 60,
scriptType: 'javascript',
command: null,
script: `
const { createRequire } = require('node:module');
const req = createRequire(process.cwd() + '/package.json');
const { chromium } = req('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
await page.goto('https://yourapp.com');
// ... your automation logic ...
await browser.close();
})();
`.trim(),
subagentConfig: null,
requiredParams: [],
});
The key pattern is createRequire(process.cwd() + '/package.json') — this resolves playwright from the node_modules of the automation's cwd, so each project can have its own Playwright version.
cd D:/repos/pi-scheduler
npm install playwright
npx playwright install chromium
node test-integration/playwright.mjs
The test is skipped gracefully if Playwright is not installed.