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-skill
3description: 'Generates Puppeteer scripts for browser automation, scraping, and PDF generation. Triggers on: "Puppeteer", "headless Chrome", "page.goto", "scrape", "PDF generation".'
4risk: critical
5source: https://github.com/LambdaTest/agent-skills/tree/main/puppeteer-skill
6source_repo: LambdaTest/agent-skills
7source_type: community
8date_added: 2026-07-01
9license: MIT
10license_source: https://github.com/LambdaTest/agent-skills/blob/main/LICENSE
11metadata:
12 source: https://skillmd.com/skills/lambdatest/puppeteer-skill
13---
14
15# Puppeteer Automation Skill
16## When to Use
17
18Use 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".
19
20
21## Core Patterns
22
23### Basic Script
24
25```javascript
26const puppeteer = require('puppeteer');
27
28(async () => {
29 const browser = await puppeteer.launch({ headless: 'new' });
30 const page = await browser.newPage();
31 await page.setViewport({ width: 1280, height: 720 });
32
33 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' });
38
39 const title = await page.title();
40 console.log('Title:', title);
41
42 await browser.close();
43})();
44```
45
46### Wait Strategies
47
48```javascript
49// Wait for selector
50await page.waitForSelector('.result', { visible: true, timeout: 10000 });
51
52// Wait for navigation
53await Promise.all([
54 page.waitForNavigation({ waitUntil: 'networkidle0' }),
55 page.click('a.nav-link'),
56]);
57
58// Wait for function
59await page.waitForFunction('document.querySelector(".count").innerText === "5"');
60
61// Wait for network request
62const response = await page.waitForResponse(resp =>
63 resp.url().includes('/api/data') && resp.status() === 200
64);
65```
66
67### Screenshot & PDF
68
69```javascript
70await page.screenshot({ path: 'screenshot.png', fullPage: true });
71await page.pdf({ path: 'page.pdf', format: 'A4', printBackground: true });
72```
73
74### Network Interception
75
76```javascript
77await page.setRequestInterception(true);
78page.on('request', request => {
79 if (request.resourceType() === 'image') request.abort();
80 else request.continue();
81});
82
83// Mock API
84page.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```
94
95### TestMu AI Cloud
96
97For 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).
98
99```javascript
100const 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};
107
108const browser = await puppeteer.connect({
109 browserWSEndpoint: `wss://cdp.lambdatest.com/puppeteer?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`,
110});
111```
112
113## Quick Reference
114
115| 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'])` |
123
124## Deep Patterns → `reference/playbook.md`
125
126| § | 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 |
140
141## Limitations
142
143- 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.