agentleFS
jholhewresjholhewres/devclaw-skills/skills/browser-automation/SKILL.md

browser-automation

Skill4 starsChanged 9 months agoMITView on GitHub

Browser automation with Playwright — navigate, click, fill forms, scrape

  • Installs packages

We split this skill into the rules it gives an agent

4 rules. 0 are common, 0 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 34 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use headless: false to see browser during development

    line 167
  2. Very specific:

    Use codegen to record actions and generate code

    line 168
  3. Very specific:

    Use waitForLoadState('networkidle') for dynamic content

    line 169
  4. Very specific:

    Use page.pause() for debugging

    line 170

“Common” is measured: kept by at least 6 in 10 of the 34 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Browser Automation

Automate web browsers using Playwright for testing, scraping, and automation.

Setup

Node.js (required):

  • macOS: brew install node
  • Ubuntu: sudo apt install nodejs npm

Playwright (browsers):

npm install -g playwright   # or: npm install playwright (project dependency)
npx playwright install        # downloads Chromium, Firefox, WebKit

Quick Scripts

# Take screenshot
npx playwright screenshot https://example.com screenshot.png

# Generate PDF
npx playwright pdf https://example.com page.pdf

Navigate & Screenshot

// script.js
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();

  await page.goto('https://example.com');
  await page.screenshot({ path: 'screenshot.png', fullPage: true });

  await browser.close();
})();
node script.js

Click & Fill Forms

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

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

  await page.goto('https://example.com/login');

  // Fill form
  await page.fill('#email', 'user@example.com');
  await page.fill('#password', 'secretpassword');

  // Click button
  await page.click('button[type="submit"]');

  // Wait for navigation
  await page.waitForURL('**/dashboard');

  await browser.close();
})();

Extract Data

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

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();

  await page.goto('https://example.com/products');

  // Extract text
  const title = await page.textContent('h1');

  // Extract multiple elements
  const products = await page.$$eval('.product', items =>
    items.map(item => ({
      name: item.querySelector('.name')?.textContent,
      price: item.querySelector('.price')?.textContent
    }))
  );

  console.log(JSON.stringify(products, null, 2));

  await browser.close();
})();

Handle Dialogs & Alerts

page.on('dialog', async dialog => {
  console.log(dialog.message());
  await dialog.accept();
});

Wait Strategies

// Wait for element
await page.waitForSelector('.loaded');

// Wait for specific text
await page.waitForSelector('text=Welcome');

// Wait for network idle
await page.waitForLoadState('networkidle');

// Wait with timeout
await page.waitForSelector('.element', { timeout: 5000 });

Authentication

// Save auth state
const context = await browser.newContext();
await context.storageState({ path: 'auth.json' });

// Load auth state
const context = await browser.newContext({ storageState: 'auth.json' });

Command Line

# Run with specific browser
npx playwright test --project=chromium
npx playwright test --project=firefox
npx playwright test --project=webkit

# Run headed (visible browser)
npx playwright test --headed

# Debug mode
npx playwright test --debug

# Generate code from actions
npx playwright codegen https://example.com

Tips

  • Use headless: false to see browser during development
  • Use codegen to record actions and generate code
  • Use waitForLoadState('networkidle') for dynamic content
  • Use page.pause() for debugging
  • Screenshots: PNG, JPEG supported

Triggers

browser automation, playwright, web scraping, automate browser, click, fill form, screenshot, web testing

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.