Loading...
Loading...
Browser automation toolkit using Playwright MCP for testing web applications. Use when asked to navigate pages, click elements, fill forms, take screenshots, verify UI components, check console logs, debug frontend issues, or validate responsive design. Supports live browser interaction and accessibility snapshots.
npx skill4agent add fugazi/test-automation-skills-agents webapp-playwright-testingActivation: This skill is triggered when you need to interact with a browser, validate UI elements, capture screenshots, or debug web application issues.
| Tool | Purpose | Example Query |
|---|---|---|
| Go to a URL | "Navigate to http://localhost:3000/login" |
| Click elements | "Click the Submit button" |
| Fill input fields | "Fill the email field with test@example.com" |
| Hover over elements | "Hover over the dropdown menu" |
| Keyboard input | "Press Enter" |
| Select from dropdown | "Select 'Option 1' from the dropdown" |
| Tool | Purpose | Example Query |
|---|---|---|
| Get accessibility tree | "Get the accessibility snapshot" |
| Capture visual state | "Take a screenshot" |
| View browser logs | "Check for console errors" |
| Monitor API calls | "Show network requests" |
| Tool | Purpose | Example Query |
|---|---|---|
| Change viewport | "Resize to mobile (375x667)" |
| Manage browser tabs | "List open tabs" |
| Close browser | "Close the browser" |
// Navigate to a page and verify heading
await page.goto('http://localhost:3000');
await expect(page.getByRole('heading', { level: 1 })).toBeVisible();// Fill out and submit a form using accessible locators
await page.getByRole('textbox', { name: 'Username' }).fill('testuser');
await page.getByRole('textbox', { name: 'Password' }).fill('password123');
await page.getByRole('button', { name: 'Login' }).click();
await expect(page).toHaveURL(/.*dashboard/);// Capture a full-page screenshot for debugging
await page.screenshot({ path: 'debug.png', fullPage: true });// Verify page structure with aria snapshot
await expect(page.getByRole('main')).toMatchAriaSnapshot(`
- main:
- heading "Welcome" [level=1]
- form:
- textbox "Email"
- textbox "Password"
- button "Login"
`);await page.getByRole('button', { name: 'Submit' }).waitFor({ state: 'visible' });const exists = await page.getByRole('alert').count() > 0;page.on('console', msg => console.log(`[${msg.type()}] ${msg.text()}`));try {
await page.getByRole('button', { name: 'Submit' }).click();
} catch (error) {
await page.screenshot({ path: 'error.png' });
throw error;
}const viewports = [
{ width: 375, height: 667, name: 'mobile' },
{ width: 768, height: 1024, name: 'tablet' },
{ width: 1920, height: 1080, name: 'desktop' },
];
for (const vp of viewports) {
await page.setViewportSize({ width: vp.width, height: vp.height });
await page.screenshot({ path: `${vp.name}.png` });
}"Navigate to http://localhost:3000/login""Get the accessibility snapshot""Take a screenshot""Show console messages""Navigate to http://localhost:3000/checkout""Take a screenshot""Get the accessibility snapshot""Click the 'Add to Cart' button""Take a screenshot"
"Check for console errors""Navigate to http://localhost:3000""Resize browser to 375x667"
"Take a screenshot"
"Verify hamburger menu is visible""Resize browser to 768x1024"
"Take a screenshot""Resize browser to 1920x1080"
"Verify navigation links are visible"| Problem | Cause | Solution |
|---|---|---|
| Element not found | Wrong locator or element not rendered | Use |
| Timeout waiting for element | Element hidden or slow to load | Check for overlays, increase timeout |
| Strict mode violation | Multiple elements match locator | Add more specific filters like |
| Click intercepted | Another element covering target | Scroll into view or wait for overlay to close |
| Console errors in app | JavaScript runtime errors | Use |
| Screenshot blank | Page not fully loaded | Wait for network idle or specific element |
| Form submission fails | Validation errors not visible | Check for error messages in snapshot |
// ✅ BEST: Role-based (accessible, resilient)
page.getByRole('button', { name: 'Submit' })
page.getByRole('textbox', { name: 'Email' })
page.getByRole('link', { name: 'Sign up' })
// ✅ GOOD: User-facing text
page.getByLabel('Email address')
page.getByPlaceholder('Enter your email')
page.getByText('Welcome back')
// ✅ GOOD: Test IDs (stable, explicit)
page.getByTestId('submit-button')
// ⚠️ AVOID: CSS selectors (brittle)
page.locator('.btn-primary')
// ❌ NEVER: XPath (extremely brittle)
page.locator('//div[@class="container"]/button[1]')| Task | Playwright MCP Query |
|---|---|
| Open page | "Navigate to {URL}" |
| Check structure | "Get the accessibility snapshot" |
| Capture evidence | "Take a screenshot" |
| Fill form | "Fill the {field} with {value}" |
| Click element | "Click the {name} button" |
| Check errors | "Show console messages" |
| Test mobile | "Resize browser to 375x667" |