Skip to content
Back to skills

Playwright Automation

ASecurity

General-purpose browser automation for testing pages, filling forms, taking screenshots, and any browser task.

  • 7 stars
  • 0 votes
  • 0 copies
  • 7 views
  • Added September 3, 2026
toolsjavascriptgojavabashnodetesting

Works with

  • cli

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 3, 2026

npx -y skills add mediar-ai/skillhubz --skill playwright-automation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Playwright Automation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Playwright Automation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mediar-ai-playwright-automation/badge)](https://www.skillsdirectory.com/skills/mediar-ai-playwright-automation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Playwright Browser Automation

General-purpose browser automation for testing pages, filling forms, taking screenshots, and any browser task.

## Prerequisites

- Node.js
- Playwright (`npm run setup` in skill directory)

## Instructions

### Critical Workflow

1. **Auto-detect dev servers** (for localhost testing):
   ```bash
   node -e "require('./lib/helpers').detectDevServers().then(s => console.log(JSON.stringify(s)))"
   ```

2. **Write scripts to /tmp** - Never clutter project directories

3. **Use visible browser** - `headless: false` by default

4. **Parameterize URLs** - Make URLs configurable

### Basic Pattern

```javascript
const { chromium } = require('playwright');

const TARGET_URL = 'http://localhost:3001';

(async () => {
  const browser = await chromium.launch({ headless: false });
  const page = await browser.newPage();

  await page.goto(TARGET_URL);
  console.log('Page loaded:', await page.title());

  await page.screenshot({ path: '/tmp/screenshot.png', fullPage: true });
  await browser.close();
})();
```

### Common Patterns

**Test Login Flow:**
```javascript
await page.goto(`${TARGET_URL}/login`);
await page.fill('input[name="email"]', 'test@example.com');
await page.fill('input[name="password"]', 'password123');
await page.click('button[type="submit"]');
await page.waitForURL('**/dashboard');
```

**Responsive Design Testing:**
```javascript
const viewports = [
  { name: 'Desktop', width: 1920, height: 1080 },
  { name: 'Tablet', width: 768, height: 1024 },
  { name: 'Mobile', width: 375, height: 667 },
];

for (const vp of viewports) {
  await page.setViewportSize({ width: vp.width, height: vp.height });
  await page.screenshot({ path: `/tmp/${vp.name.toLowerCase()}.png` });
}
```

**Check Broken Links:**
```javascript
const links = await page.locator('a[href^="http"]').all();
for (const link of links) {
  const href = await link.getAttribute('href');
  const response = await page.request.head(href);
  console.log(href, response.ok() ? '✅' : '❌');
}
```

### Helper Functions

- `detectDevServers()` - Find running dev servers
- `safeClick(page, selector)` - Click with retry
- `safeType(page, selector, text)` - Type with clear
- `takeScreenshot(page, name)` - Timestamped screenshot
- `handleCookieBanner(page)` - Dismiss cookie popups

## Guidelines

1. Detect servers FIRST for localhost testing
2. Write test files to `/tmp/playwright-test-*.js`
3. Use `headless: false` unless explicitly requested
4. Use `waitForURL`, `waitForSelector` instead of fixed timeouts
5. Always use try-catch for robust automation

## Notes

- Custom code for any browser task
- Auto-detects running dev servers
- Test files auto-cleaned from /tmp

Source: lackeyjb/playwright-skill

Files in this skill

  • manifest.json364 B
  • skill.md2.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.