Puppeteer Automation Skill
When to Use
Use this skill when you need generates Puppeteer scripts for browser automation, scraping, and PDF generation. Triggers on: "Puppeteer", "headless Chrome", "page.goto", "scrape", "PDF generation".
Core Patterns
Basic Script
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
await page.setViewport({ width: 1280, height: 720 });
await page.goto('https://example.com', { waitUntil: 'networkidle0' });
await page.type('#username', 'user@test.com');
await page.type('#password', 'password123');
await page.click('button[type="submit"]');
await page.waitForNavigation({ waitUntil: 'networkidle0' });
const title = await page.title();
console.log('Title:', title);
await browser.close();
})();
Wait Strategies
// Wait for selector
await page.waitForSelector('.result', { visible: true, timeout: 10000 });
// Wait for navigation
await Promise.all([
page.waitForNavigation({ waitUntil: 'networkidle0' }),
page.click('a.nav-link'),
]);
// Wait for function
await page.waitForFunction('document.querySelector(".count").innerText === "5"');
// Wait for network request
const response = await page.waitForResponse(resp =>
resp.url().includes('/api/data') && resp.status() === 200
);
Screenshot & PDF
await page.screenshot({ path: 'screenshot.png', fullPage: true });
await page.pdf({ path: 'page.pdf', format: 'A4', printBackground: true });
Network Interception
await page.setRequestInterception(true);
page.on('request', request => {
if (request.resourceType() === 'image') request.abort();
else request.continue();
});
// Mock API
page.on('request', request => {
if (request.url().includes('/api/data')) {
request.respond({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ items: [] }),
});
} else request.continue();
});
TestMu AI Cloud
For full setup, capabilities, and shared capability reference, see reference/cloud-integration.md.
const capabilities = {
browserName: 'Chrome', browserVersion: 'latest',
'LT:Options': {
platform: 'Windows 11', build: 'Puppeteer Build',
user: process.env.LT_USERNAME, accessKey: process.env.LT_ACCESS_KEY,
},
};
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://cdp.lambdatest.com/puppeteer?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`,
});
Quick Reference
| Task |
Code |
| Launch headed |
puppeteer.launch({ headless: false }) |
| Evaluate JS |
await page.evaluate(() => document.title) |
| Extract text |
await page.$eval('.el', el => el.textContent) |
| Extract all |
await page.$$eval('.items', els => els.map(e => e.textContent)) |
| Set cookie |
await page.setCookie({ name: 'token', value: 'abc' }) |
| Emulate device |
await page.emulate(puppeteer.devices['iPhone 12']) |
Deep Patterns → reference/playbook.md
| § |
Section |
Lines |
| 1 |
Production Setup & Configuration |
Launch options, Jest integration |
| 2 |
Page Object Pattern |
BasePage, LoginPage, DashboardPage |
| 3 |
Network Interception & Mocking |
Request mock, response capture |
| 4 |
Wait Strategies |
DOM, network, custom conditions |
| 5 |
Screenshots, PDF & Media |
Full page, clip, PDF, video |
| 6 |
Authentication & Cookies |
API login, session save/restore |
| 7 |
iFrame, Dialog & File Operations |
Upload, download, dialogs |
| 8 |
Performance & Metrics |
Web Vitals, Lighthouse, coverage |
| 9 |
Accessibility Testing |
axe-core integration |
| 10 |
CI/CD Integration |
GitHub Actions, Docker |
| 11 |
Debugging Quick-Reference |
11 common problems |
| 12 |
Best Practices Checklist |
13 items |
Limitations
- Use this skill only when the task clearly matches its upstream source and local project context.
- Verify commands, generated code, dependencies, credentials, and external service behavior before applying changes.
- Do not treat examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.
1---2name: puppeteer-skill3description: 'Generates Puppeteer scripts for browser automation, scraping, and PDF generation. Triggers on: "Puppeteer", "headless Chrome", "page.goto", "scrape", "PDF generation".'4risk: critical5source: https://github.com/LambdaTest/agent-skills/tree/main/puppeteer-skill6source_repo: LambdaTest/agent-skills7source_type: community8date_added: 2026-07-019license: MIT10license_source: https://github.com/LambdaTest/agent-skills/blob/main/LICENSE11metadata:12 source: https://skillmd.com/skills/lingxling/puppeteer-skill13---1415# Puppeteer Automation Skill16## When to Use1718Use this skill when you need generates Puppeteer scripts for browser automation, scraping, and PDF generation. Triggers on: "Puppeteer", "headless Chrome", "page.goto", "scrape", "PDF generation".192021## Core Patterns2223### Basic Script2425```javascript26const puppeteer = require('puppeteer');2728(async () => {29 const browser = await puppeteer.launch({ headless: 'new' });30 const page = await browser.newPage();31 await page.setViewport({ width: 1280, height: 720 });3233 await page.goto('https://example.com', { waitUntil: 'networkidle0' });34 await page.type('#username', 'user@test.com');35 await page.type('#password', 'password123');36 await page.click('button[type="submit"]');37 await page.waitForNavigation({ waitUntil: 'networkidle0' });3839 const title = await page.title();40 console.log('Title:', title);4142 await browser.close();43})();44```4546### Wait Strategies4748```javascript49// Wait for selector50await page.waitForSelector('.result', { visible: true, timeout: 10000 });5152// Wait for navigation53await Promise.all([54 page.waitForNavigation({ waitUntil: 'networkidle0' }),55 page.click('a.nav-link'),56]);5758// Wait for function59await page.waitForFunction('document.querySelector(".count").innerText === "5"');6061// Wait for network request62const response = await page.waitForResponse(resp =>63 resp.url().includes('/api/data') && resp.status() === 20064);65```6667### Screenshot & PDF6869```javascript70await page.screenshot({ path: 'screenshot.png', fullPage: true });71await page.pdf({ path: 'page.pdf', format: 'A4', printBackground: true });72```7374### Network Interception7576```javascript77await page.setRequestInterception(true);78page.on('request', request => {79 if (request.resourceType() === 'image') request.abort();80 else request.continue();81});8283// Mock API84page.on('request', request => {85 if (request.url().includes('/api/data')) {86 request.respond({87 status: 200,88 contentType: 'application/json',89 body: JSON.stringify({ items: [] }),90 });91 } else request.continue();92});93```9495### TestMu AI Cloud9697For full setup, capabilities, and shared capability reference, see [reference/cloud-integration.md](https://github.com/LambdaTest/agent-skills/tree/main/puppeteer-skill/reference/cloud-integration.md).9899```javascript100const capabilities = {101 browserName: 'Chrome', browserVersion: 'latest',102 'LT:Options': {103 platform: 'Windows 11', build: 'Puppeteer Build',104 user: process.env.LT_USERNAME, accessKey: process.env.LT_ACCESS_KEY,105 },106};107108const browser = await puppeteer.connect({109 browserWSEndpoint: `wss://cdp.lambdatest.com/puppeteer?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`,110});111```112113## Quick Reference114115| Task | Code |116|------|------|117| Launch headed | `puppeteer.launch({ headless: false })` |118| Evaluate JS | `await page.evaluate(() => document.title)` |119| Extract text | `await page.$eval('.el', el => el.textContent)` |120| Extract all | `await page.$$eval('.items', els => els.map(e => e.textContent))` |121| Set cookie | `await page.setCookie({ name: 'token', value: 'abc' })` |122| Emulate device | `await page.emulate(puppeteer.devices['iPhone 12'])` |123124## Deep Patterns → `reference/playbook.md`125126| § | Section | Lines |127|---|---------|-------|128| 1 | Production Setup & Configuration | Launch options, Jest integration |129| 2 | Page Object Pattern | BasePage, LoginPage, DashboardPage |130| 3 | Network Interception & Mocking | Request mock, response capture |131| 4 | Wait Strategies | DOM, network, custom conditions |132| 5 | Screenshots, PDF & Media | Full page, clip, PDF, video |133| 6 | Authentication & Cookies | API login, session save/restore |134| 7 | iFrame, Dialog & File Operations | Upload, download, dialogs |135| 8 | Performance & Metrics | Web Vitals, Lighthouse, coverage |136| 9 | Accessibility Testing | axe-core integration |137| 10 | CI/CD Integration | GitHub Actions, Docker |138| 11 | Debugging Quick-Reference | 11 common problems |139| 12 | Best Practices Checklist | 13 items |140141## Limitations142143- Use this skill only when the task clearly matches its upstream source and local project context.144- Verify commands, generated code, dependencies, credentials, and external service behavior before applying changes.145- Do not treat examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.