Create and execute automated browser workflows using Playwright. Generate scripts for testing, web scraping, form automation, and UI interaction sequences.
Generate Playwright scripts for browser automation workflows like testing, scraping, and form filling. Use this when you need reusable, code-first automation that can run in CI/CD pipelines.
/plugin marketplace add anton-abyzov/specweave/plugin install sw-docs@specweaveCreate and execute automated browser workflows using Playwright. Generate scripts for testing, web scraping, form automation, and UI interaction sequences.
/sw-ui:ui-automate <workflow-name> [options]
Why Code-First? Anthropic research shows code execution beats MCP tool calls with 98% token reduction. Playwright code is reusable, committable, CI-runnable, and deterministic.
/sw-ui:ui-automate form-fill --url https://example.com/form \
--fields "email=test@example.com,name=John Doe"
/sw-ui:ui-automate scrape --url https://example.com/products \
--selectors "title=h1.product-title,price=.price"
/sw-ui:ui-automate test-login --url https://example.com/login \
--steps "fill:email,fill:password,click:submit,wait:dashboard"
/sw-ui:ui-automate screenshot --url https://example.com \
--fullPage --output screenshots/homepage.png
/sw-ui:ui-automate navigate --start https://example.com \
--flow "home>products>cart>checkout"
--url <url> - Starting URL for automation--browser <browser> - chromium, firefox, webkit (default: chromium)--headless - Run in headless mode (default: true)--output <path> - Output directory for artifacts--steps <steps> - Comma-separated list of actions--selectors <selectors> - CSS selectors for elements--fields <fields> - Form field values (key=value pairs)--wait <selector> - Wait for element before proceeding--timeout <ms> - Max time to wait for operations (default: 30000)--screenshot - Capture screenshots at each step--extract <selector> - Extract text/attributes from elements--save-html - Save page HTML at key stepsimport { chromium, Browser, Page } from 'playwright';
async function automateWorkflow() {
const browser: Browser = await chromium.launch({ headless: true });
const page: Page = await browser.newPage();
try {
// Step 1: Navigate
await page.goto('https://example.com', { waitUntil: 'networkidle' });
// Step 2: Fill form
await page.fill('#email', 'test@example.com');
await page.fill('#password', 'secure-password');
// Step 3: Submit
await page.click('button[type="submit"]');
// Step 4: Wait for navigation
await page.waitForSelector('.dashboard', { timeout: 5000 });
// Step 5: Capture result
await page.screenshot({ path: 'result.png', fullPage: true });
console.log('✓ Automation completed successfully');
} catch (error) {
console.error('✗ Automation failed:', error.message);
await page.screenshot({ path: 'error.png' });
throw error;
} finally {
await browser.close();
}
}
automateWorkflow();
Automate critical user flows to catch UI regressions early.
Extract product information, prices, availability from multiple pages.
Simulate multiple users interacting with the application.
Capture screenshots across environments to detect visual changes.
Bulk-fill forms with test data for QA purposes.
await page.click('button', { timeout: 5000 })
.catch(async () => {
console.log('Retrying click...');
await page.click('button', { force: true });
});
const selectors = ['#submit', '.submit-btn', 'button[type="submit"]'];
for (const selector of selectors) {
if (await page.locator(selector).count() > 0) {
await page.click(selector);
break;
}
}
/sw-ui:ui-inspect - Inspect page elements for selectors/sw-testing:e2e-setup - Set up full E2E testing framework/sw-testing:test-generate - Generate test files from automation scriptsPLAYWRIGHT_BROWSERS_PATH - Custom browser binaries locationPLAYWRIGHT_SKIP_BROWSER_DOWNLOAD - Skip browser download on installHEADLESS - Default headless mode (true/false)