@assertrx/dino 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +293 -0
- package/extensions/dino.ts +70 -0
- package/extensions/mabl-mcp.ts +306 -0
- package/extensions/playwright-mcp.ts +142 -0
- package/package.json +47 -0
- package/prompts/create-pr.md +110 -0
- package/prompts/generate-bdd-from-url.md +65 -0
- package/prompts/generate-pom-from-url-cli.md +48 -0
- package/prompts/generate-pom-from-url.md +45 -0
- package/prompts/generate-spec-from-feature.md +64 -0
- package/prompts/heal-playwright-failures.md +106 -0
- package/prompts/setup-playwright.md +81 -0
- package/scripts/start-dino.cmd +8 -0
- package/scripts/start-dino.mjs +226 -0
- package/scripts/start-dino.ps1 +9 -0
- package/scripts/start-dino.sh +10 -0
- package/skills/acli/SKILL.md +292 -0
- package/skills/bdd-gherkin/SKILL.md +552 -0
- package/skills/build-review-interface/SKILL.md +96 -0
- package/skills/error-analysis/SKILL.md +164 -0
- package/skills/eval-audit/SKILL.md +183 -0
- package/skills/evaluate-rag/SKILL.md +177 -0
- package/skills/generate-synthetic-data/SKILL.md +131 -0
- package/skills/mabl-mcp/SKILL.md +79 -0
- package/skills/playwright-cli/SKILL.md +246 -0
- package/skills/playwright-cli/advanced-workflows.md +679 -0
- package/skills/playwright-cli/core-commands.md +375 -0
- package/skills/playwright-cli/device-emulation.md +475 -0
- package/skills/playwright-cli/request-mocking.md +373 -0
- package/skills/playwright-cli/running-custom-code.md +553 -0
- package/skills/playwright-cli/screenshots-and-media.md +457 -0
- package/skills/playwright-cli/session-management.md +425 -0
- package/skills/playwright-cli/storage-and-auth.md +487 -0
- package/skills/playwright-cli/test-generation.md +336 -0
- package/skills/playwright-cli/tracing-and-debugging.md +501 -0
- package/skills/playwright-core/SKILL.md +101 -0
- package/skills/playwright-core/accessibility.md +1517 -0
- package/skills/playwright-core/angular.md +1086 -0
- package/skills/playwright-core/api-testing.md +1623 -0
- package/skills/playwright-core/assertions-and-waiting.md +703 -0
- package/skills/playwright-core/auth-flows.md +1081 -0
- package/skills/playwright-core/authentication.md +1409 -0
- package/skills/playwright-core/browser-apis.md +673 -0
- package/skills/playwright-core/browser-extensions.md +319 -0
- package/skills/playwright-core/canvas-and-webgl.md +494 -0
- package/skills/playwright-core/clock-and-time-mocking.md +427 -0
- package/skills/playwright-core/common-pitfalls.md +1318 -0
- package/skills/playwright-core/component-testing.md +1179 -0
- package/skills/playwright-core/configuration.md +731 -0
- package/skills/playwright-core/crud-testing.md +945 -0
- package/skills/playwright-core/debugging.md +827 -0
- package/skills/playwright-core/drag-and-drop.md +992 -0
- package/skills/playwright-core/electron-testing.md +622 -0
- package/skills/playwright-core/error-and-edge-cases.md +1181 -0
- package/skills/playwright-core/error-index.md +1903 -0
- package/skills/playwright-core/file-operations.md +749 -0
- package/skills/playwright-core/file-upload-download.md +1012 -0
- package/skills/playwright-core/fixtures-and-hooks.md +1072 -0
- package/skills/playwright-core/flaky-tests.md +883 -0
- package/skills/playwright-core/forms-and-validation.md +1056 -0
- package/skills/playwright-core/i18n-and-localization.md +622 -0
- package/skills/playwright-core/iframes-and-shadow-dom.md +488 -0
- package/skills/playwright-core/locator-strategy.md +588 -0
- package/skills/playwright-core/locators.md +743 -0
- package/skills/playwright-core/mobile-and-responsive.md +1669 -0
- package/skills/playwright-core/multi-context-and-popups.md +581 -0
- package/skills/playwright-core/multi-user-and-collaboration.md +477 -0
- package/skills/playwright-core/network-mocking.md +1395 -0
- package/skills/playwright-core/nextjs.md +1013 -0
- package/skills/playwright-core/performance-testing.md +608 -0
- package/skills/playwright-core/react.md +1082 -0
- package/skills/playwright-core/search-and-filter.md +1366 -0
- package/skills/playwright-core/security-testing.md +624 -0
- package/skills/playwright-core/service-workers-and-pwa.md +524 -0
- package/skills/playwright-core/test-architecture.md +569 -0
- package/skills/playwright-core/test-data-management.md +1209 -0
- package/skills/playwright-core/test-organization.md +947 -0
- package/skills/playwright-core/third-party-integrations.md +754 -0
- package/skills/playwright-core/trace-analysis.md +161 -0
- package/skills/playwright-core/visual-regression.md +1027 -0
- package/skills/playwright-core/vue.md +1162 -0
- package/skills/playwright-core/websockets-and-realtime.md +623 -0
- package/skills/playwright-core/when-to-mock.md +827 -0
- package/skills/playwright-pom/SKILL.md +94 -0
- package/skills/playwright-pom/page-object-model.md +921 -0
- package/skills/playwright-pom/pom-vs-fixtures-vs-helpers.md +937 -0
- package/skills/validate-evaluator/SKILL.md +215 -0
- package/skills/write-judge-prompt/SKILL.md +144 -0
- package/themes/dino.json +66 -0
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
# Screenshots and Media
|
|
2
|
+
|
|
3
|
+
> **When to use**: Capturing visual evidence of page state — screenshots for verification, video recordings for demos or debugging, PDF exports for documentation, viewport resizing for responsive testing.
|
|
4
|
+
> **Prerequisites**: [core-commands.md](core-commands.md) for basic CLI usage
|
|
5
|
+
|
|
6
|
+
## Quick Reference
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
# Screenshots
|
|
10
|
+
playwright-cli screenshot # Full page screenshot
|
|
11
|
+
playwright-cli screenshot e5 # Element screenshot
|
|
12
|
+
playwright-cli screenshot --filename=checkout.png # Custom filename
|
|
13
|
+
|
|
14
|
+
# PDF
|
|
15
|
+
playwright-cli pdf --filename=report.pdf # Save page as PDF
|
|
16
|
+
|
|
17
|
+
# Video
|
|
18
|
+
playwright-cli video-start # Start recording
|
|
19
|
+
playwright-cli video-stop demo.webm # Stop and save
|
|
20
|
+
|
|
21
|
+
# Viewport
|
|
22
|
+
playwright-cli resize 1920 1080 # Desktop
|
|
23
|
+
playwright-cli resize 375 812 # Mobile
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Screenshots
|
|
27
|
+
|
|
28
|
+
### Page Screenshot
|
|
29
|
+
|
|
30
|
+
Capture the entire visible viewport:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Auto-generated filename
|
|
34
|
+
playwright-cli screenshot
|
|
35
|
+
|
|
36
|
+
# Custom filename
|
|
37
|
+
playwright-cli screenshot --filename=homepage.png
|
|
38
|
+
playwright-cli screenshot --filename=screenshots/checkout-step3.png
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Element Screenshot
|
|
42
|
+
|
|
43
|
+
Capture a specific element only — useful for component-level verification:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Screenshot a single element by ref
|
|
47
|
+
playwright-cli snapshot # Get refs first
|
|
48
|
+
playwright-cli screenshot e5 # Capture just element e5
|
|
49
|
+
|
|
50
|
+
# With custom filename
|
|
51
|
+
playwright-cli screenshot e5 --filename=product-card.png
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Full-Page Screenshot
|
|
55
|
+
|
|
56
|
+
Capture the entire scrollable page, not just the viewport:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
playwright-cli run-code "async page => {
|
|
60
|
+
await page.screenshot({ path: 'full-page.png', fullPage: true });
|
|
61
|
+
return 'Saved full-page screenshot';
|
|
62
|
+
}"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Screenshot with Options
|
|
66
|
+
|
|
67
|
+
Use `run-code` for advanced screenshot options:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Full page with quality settings (JPEG)
|
|
71
|
+
playwright-cli run-code "async page => {
|
|
72
|
+
await page.screenshot({
|
|
73
|
+
path: 'optimized.jpg',
|
|
74
|
+
type: 'jpeg',
|
|
75
|
+
quality: 80,
|
|
76
|
+
fullPage: true
|
|
77
|
+
});
|
|
78
|
+
}"
|
|
79
|
+
|
|
80
|
+
# Clip to specific region
|
|
81
|
+
playwright-cli run-code "async page => {
|
|
82
|
+
await page.screenshot({
|
|
83
|
+
path: 'header-region.png',
|
|
84
|
+
clip: { x: 0, y: 0, width: 1280, height: 200 }
|
|
85
|
+
});
|
|
86
|
+
}"
|
|
87
|
+
|
|
88
|
+
# With transparent background (for elements with transparency)
|
|
89
|
+
playwright-cli run-code "async page => {
|
|
90
|
+
await page.screenshot({
|
|
91
|
+
path: 'transparent.png',
|
|
92
|
+
omitBackground: true
|
|
93
|
+
});
|
|
94
|
+
}"
|
|
95
|
+
|
|
96
|
+
# Screenshot with mask (hide dynamic content)
|
|
97
|
+
playwright-cli run-code "async page => {
|
|
98
|
+
await page.screenshot({
|
|
99
|
+
path: 'masked.png',
|
|
100
|
+
mask: [
|
|
101
|
+
page.locator('.timestamp'),
|
|
102
|
+
page.locator('.user-avatar'),
|
|
103
|
+
page.locator('.ad-banner')
|
|
104
|
+
]
|
|
105
|
+
});
|
|
106
|
+
}"
|
|
107
|
+
|
|
108
|
+
# Disable animations before screenshot
|
|
109
|
+
playwright-cli run-code "async page => {
|
|
110
|
+
await page.evaluate(() => {
|
|
111
|
+
document.querySelectorAll('*').forEach(el => {
|
|
112
|
+
el.style.animation = 'none';
|
|
113
|
+
el.style.transition = 'none';
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
await page.screenshot({ path: 'no-animations.png' });
|
|
117
|
+
}"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Element Screenshot with Options
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
playwright-cli run-code "async page => {
|
|
124
|
+
const element = page.getByTestId('pricing-card');
|
|
125
|
+
await element.screenshot({
|
|
126
|
+
path: 'pricing-card.png',
|
|
127
|
+
omitBackground: true
|
|
128
|
+
});
|
|
129
|
+
}"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Responsive Screenshots
|
|
133
|
+
|
|
134
|
+
Capture how the page looks at different viewport sizes:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Desktop (1920x1080)
|
|
138
|
+
playwright-cli resize 1920 1080
|
|
139
|
+
playwright-cli screenshot --filename=desktop.png
|
|
140
|
+
|
|
141
|
+
# Laptop (1366x768)
|
|
142
|
+
playwright-cli resize 1366 768
|
|
143
|
+
playwright-cli screenshot --filename=laptop.png
|
|
144
|
+
|
|
145
|
+
# Tablet landscape (1024x768)
|
|
146
|
+
playwright-cli resize 1024 768
|
|
147
|
+
playwright-cli screenshot --filename=tablet-landscape.png
|
|
148
|
+
|
|
149
|
+
# Tablet portrait (768x1024)
|
|
150
|
+
playwright-cli resize 768 1024
|
|
151
|
+
playwright-cli screenshot --filename=tablet-portrait.png
|
|
152
|
+
|
|
153
|
+
# Mobile (375x812 — iPhone X)
|
|
154
|
+
playwright-cli resize 375 812
|
|
155
|
+
playwright-cli screenshot --filename=mobile.png
|
|
156
|
+
|
|
157
|
+
# Mobile small (320x568 — iPhone SE)
|
|
158
|
+
playwright-cli resize 320 568
|
|
159
|
+
playwright-cli screenshot --filename=mobile-small.png
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Automated Responsive Screenshots
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
playwright-cli run-code "async page => {
|
|
166
|
+
const viewports = [
|
|
167
|
+
{ name: 'desktop', width: 1920, height: 1080 },
|
|
168
|
+
{ name: 'laptop', width: 1366, height: 768 },
|
|
169
|
+
{ name: 'tablet', width: 768, height: 1024 },
|
|
170
|
+
{ name: 'mobile', width: 375, height: 812 },
|
|
171
|
+
{ name: 'mobile-sm', width: 320, height: 568 }
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
for (const vp of viewports) {
|
|
175
|
+
await page.setViewportSize({ width: vp.width, height: vp.height });
|
|
176
|
+
await page.waitForTimeout(500); // Allow layout to settle
|
|
177
|
+
await page.screenshot({ path: \`responsive-\${vp.name}.png\` });
|
|
178
|
+
}
|
|
179
|
+
return 'Captured ' + viewports.length + ' responsive screenshots';
|
|
180
|
+
}"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## PDF Export
|
|
184
|
+
|
|
185
|
+
Generate PDF documents from web pages — useful for reports, invoices, and documentation.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Basic PDF
|
|
189
|
+
playwright-cli pdf --filename=page.pdf
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Advanced PDF Options
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# PDF with custom options
|
|
196
|
+
playwright-cli run-code "async page => {
|
|
197
|
+
await page.pdf({
|
|
198
|
+
path: 'report.pdf',
|
|
199
|
+
format: 'A4',
|
|
200
|
+
printBackground: true,
|
|
201
|
+
margin: { top: '1cm', right: '1cm', bottom: '1cm', left: '1cm' }
|
|
202
|
+
});
|
|
203
|
+
return 'PDF saved';
|
|
204
|
+
}"
|
|
205
|
+
|
|
206
|
+
# Letter format with header/footer
|
|
207
|
+
playwright-cli run-code "async page => {
|
|
208
|
+
await page.pdf({
|
|
209
|
+
path: 'document.pdf',
|
|
210
|
+
format: 'Letter',
|
|
211
|
+
printBackground: true,
|
|
212
|
+
displayHeaderFooter: true,
|
|
213
|
+
headerTemplate: '<div style=\"font-size:10px; text-align:center; width:100%;\">Company Report</div>',
|
|
214
|
+
footerTemplate: '<div style=\"font-size:10px; text-align:center; width:100%;\">Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span></div>',
|
|
215
|
+
margin: { top: '2cm', bottom: '2cm', left: '1cm', right: '1cm' }
|
|
216
|
+
});
|
|
217
|
+
}"
|
|
218
|
+
|
|
219
|
+
# Landscape PDF
|
|
220
|
+
playwright-cli run-code "async page => {
|
|
221
|
+
await page.pdf({
|
|
222
|
+
path: 'landscape.pdf',
|
|
223
|
+
landscape: true,
|
|
224
|
+
format: 'A4',
|
|
225
|
+
printBackground: true
|
|
226
|
+
});
|
|
227
|
+
}"
|
|
228
|
+
|
|
229
|
+
# Specific pages only
|
|
230
|
+
playwright-cli run-code "async page => {
|
|
231
|
+
await page.pdf({
|
|
232
|
+
path: 'partial.pdf',
|
|
233
|
+
pageRanges: '1-3',
|
|
234
|
+
format: 'A4'
|
|
235
|
+
});
|
|
236
|
+
}"
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Note**: PDF generation only works with Chromium-based browsers, not Firefox or WebKit.
|
|
240
|
+
|
|
241
|
+
### Print Stylesheet Preview
|
|
242
|
+
|
|
243
|
+
Before generating a PDF, switch to print media to see the print layout:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
playwright-cli run-code "async page => {
|
|
247
|
+
await page.emulateMedia({ media: 'print' });
|
|
248
|
+
}"
|
|
249
|
+
playwright-cli screenshot --filename=print-preview.png
|
|
250
|
+
playwright-cli pdf --filename=output.pdf
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Video Recording
|
|
254
|
+
|
|
255
|
+
Record browser sessions as WebM video files.
|
|
256
|
+
|
|
257
|
+
For simple "start recording now, stop later" flows, `video-start` and `video-stop` remain fine. For Playwright 1.59+ workflows that need precise start and stop control, action callouts, chapter titles, or richer review videos, prefer `page.screencast`.
|
|
258
|
+
|
|
259
|
+
### Screencast API (Playwright 1.59+)
|
|
260
|
+
|
|
261
|
+
Use `page.screencast` when you need a richer artifact than plain video recording.
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# Start a screencast with an explicit output path
|
|
265
|
+
playwright-cli run-code "async page => {
|
|
266
|
+
await page.screencast.start({
|
|
267
|
+
path: 'recordings/checkout-walkthrough.webm',
|
|
268
|
+
size: { width: 1280, height: 800 }
|
|
269
|
+
});
|
|
270
|
+
return 'Screencast started';
|
|
271
|
+
}"
|
|
272
|
+
|
|
273
|
+
# Stop and finalize the file
|
|
274
|
+
playwright-cli run-code "async page => {
|
|
275
|
+
await page.screencast.stop();
|
|
276
|
+
return 'Screencast saved';
|
|
277
|
+
}"
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Annotated Screencasts
|
|
281
|
+
|
|
282
|
+
Playwright 1.59 adds built-in action annotations and chapter overlays, which are ideal for demos, debugging, and agent receipts.
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
playwright-cli run-code "async page => {
|
|
286
|
+
await page.screencast.start({ path: 'recordings/annotated-demo.webm' });
|
|
287
|
+
await page.screencast.showActions({
|
|
288
|
+
position: 'top-right',
|
|
289
|
+
duration: 900,
|
|
290
|
+
fontSize: 20
|
|
291
|
+
});
|
|
292
|
+
await page.screencast.showChapter('Checkout flow', {
|
|
293
|
+
description: 'Verify coupon entry and updated totals',
|
|
294
|
+
duration: 1500
|
|
295
|
+
});
|
|
296
|
+
return 'Annotated screencast started';
|
|
297
|
+
}"
|
|
298
|
+
|
|
299
|
+
# Perform the flow with normal playwright-cli commands here
|
|
300
|
+
# ...
|
|
301
|
+
|
|
302
|
+
playwright-cli run-code "async page => {
|
|
303
|
+
await page.screencast.showChapter('Done', {
|
|
304
|
+
description: 'Coupon applied and totals updated'
|
|
305
|
+
});
|
|
306
|
+
await page.screencast.stop();
|
|
307
|
+
return 'Annotated screencast saved';
|
|
308
|
+
}"
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### When To Use Screencast vs Video Recording
|
|
312
|
+
|
|
313
|
+
| Need | Best choice |
|
|
314
|
+
|------|-------------|
|
|
315
|
+
| Fast ad-hoc browser capture from the CLI | `video-start` / `video-stop` |
|
|
316
|
+
| Precise start and stop around one flow | `page.screencast.start()` / `stop()` |
|
|
317
|
+
| Action callouts during recording | `page.screencast.showActions()` |
|
|
318
|
+
| Chapter titles for walkthrough videos | `page.screencast.showChapter()` |
|
|
319
|
+
| Agent evidence / review receipts | `page.screencast` |
|
|
320
|
+
|
|
321
|
+
### Basic Recording
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
# Start recording
|
|
325
|
+
playwright-cli video-start
|
|
326
|
+
|
|
327
|
+
# Perform actions (everything is recorded)
|
|
328
|
+
playwright-cli open https://example.com
|
|
329
|
+
playwright-cli snapshot
|
|
330
|
+
playwright-cli click e1
|
|
331
|
+
playwright-cli fill e2 "test input"
|
|
332
|
+
playwright-cli click e5
|
|
333
|
+
|
|
334
|
+
# Stop and save
|
|
335
|
+
playwright-cli video-stop demo.webm
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Recording with Descriptive Names
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
playwright-cli video-start
|
|
342
|
+
# ... login flow ...
|
|
343
|
+
playwright-cli video-stop recordings/login-flow-2024-01-15.webm
|
|
344
|
+
|
|
345
|
+
playwright-cli video-start
|
|
346
|
+
# ... checkout flow ...
|
|
347
|
+
playwright-cli video-stop recordings/checkout-happy-path.webm
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Use Cases
|
|
351
|
+
|
|
352
|
+
| Scenario | Benefit |
|
|
353
|
+
|----------|---------|
|
|
354
|
+
| Bug reproduction | Share exact steps with developers |
|
|
355
|
+
| Demo creation | Show feature flows to stakeholders |
|
|
356
|
+
| Documentation | Record UI walkthroughs |
|
|
357
|
+
| QA evidence | Prove a test scenario was completed |
|
|
358
|
+
| Debugging | Watch what happened frame-by-frame |
|
|
359
|
+
|
|
360
|
+
## Viewport Management
|
|
361
|
+
|
|
362
|
+
Control the browser viewport for responsive testing:
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
# Common desktop sizes
|
|
366
|
+
playwright-cli resize 1920 1080 # Full HD
|
|
367
|
+
playwright-cli resize 1440 900 # MacBook Pro 15"
|
|
368
|
+
playwright-cli resize 1366 768 # Common laptop
|
|
369
|
+
playwright-cli resize 1280 720 # HD
|
|
370
|
+
|
|
371
|
+
# Tablet sizes
|
|
372
|
+
playwright-cli resize 1024 768 # iPad landscape
|
|
373
|
+
playwright-cli resize 768 1024 # iPad portrait
|
|
374
|
+
playwright-cli resize 834 1194 # iPad Pro 11"
|
|
375
|
+
|
|
376
|
+
# Mobile sizes
|
|
377
|
+
playwright-cli resize 430 932 # iPhone 14 Pro Max
|
|
378
|
+
playwright-cli resize 390 844 # iPhone 14
|
|
379
|
+
playwright-cli resize 375 812 # iPhone X/11/12/13
|
|
380
|
+
playwright-cli resize 360 800 # Galaxy S21
|
|
381
|
+
playwright-cli resize 320 568 # iPhone SE
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## Common Patterns
|
|
385
|
+
|
|
386
|
+
### Before/After Comparison
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
# Before action
|
|
390
|
+
playwright-cli screenshot --filename=before.png
|
|
391
|
+
playwright-cli click e5
|
|
392
|
+
# After action
|
|
393
|
+
playwright-cli screenshot --filename=after.png
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Full Documentation Suite
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
playwright-cli open https://app.example.com
|
|
400
|
+
|
|
401
|
+
# Login page
|
|
402
|
+
playwright-cli screenshot --filename=docs/01-login.png
|
|
403
|
+
|
|
404
|
+
# Fill and submit
|
|
405
|
+
playwright-cli fill e1 "demo@example.com"
|
|
406
|
+
playwright-cli fill e2 "demo-password"
|
|
407
|
+
playwright-cli screenshot --filename=docs/02-login-filled.png
|
|
408
|
+
|
|
409
|
+
playwright-cli click e3
|
|
410
|
+
playwright-cli screenshot --filename=docs/03-dashboard.png
|
|
411
|
+
|
|
412
|
+
# Navigate to settings
|
|
413
|
+
playwright-cli goto https://app.example.com/settings
|
|
414
|
+
playwright-cli screenshot --filename=docs/04-settings.png
|
|
415
|
+
|
|
416
|
+
# Generate PDF of documentation page
|
|
417
|
+
playwright-cli goto https://app.example.com/docs
|
|
418
|
+
playwright-cli pdf --filename=docs/user-guide.pdf
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### Dark Mode vs Light Mode Screenshots
|
|
422
|
+
|
|
423
|
+
```bash
|
|
424
|
+
playwright-cli open https://example.com
|
|
425
|
+
|
|
426
|
+
# Light mode
|
|
427
|
+
playwright-cli run-code "async page => { await page.emulateMedia({ colorScheme: 'light' }); }"
|
|
428
|
+
playwright-cli screenshot --filename=light-mode.png
|
|
429
|
+
|
|
430
|
+
# Dark mode
|
|
431
|
+
playwright-cli run-code "async page => { await page.emulateMedia({ colorScheme: 'dark' }); }"
|
|
432
|
+
playwright-cli screenshot --filename=dark-mode.png
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### Cross-Browser Screenshot Comparison
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
#!/bin/bash
|
|
439
|
+
URL="https://example.com"
|
|
440
|
+
|
|
441
|
+
for browser in chrome firefox webkit; do
|
|
442
|
+
playwright-cli -s=$browser open $URL --browser=$browser
|
|
443
|
+
playwright-cli -s=$browser screenshot --filename="comparison-$browser.png"
|
|
444
|
+
done
|
|
445
|
+
|
|
446
|
+
playwright-cli close-all
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
## Tips
|
|
450
|
+
|
|
451
|
+
- **Always set viewport before screenshotting** — `resize` before `screenshot` for consistent dimensions
|
|
452
|
+
- **Use descriptive filenames** — `checkout-step3-error.png` not `screenshot-1.png`
|
|
453
|
+
- **Create output directories first** — `mkdir -p screenshots/` before using subdirectory paths
|
|
454
|
+
- **Full-page for long content** — use `fullPage: true` via `run-code` for scrollable pages
|
|
455
|
+
- **Mask dynamic content** — hide timestamps, avatars, and ads to get deterministic screenshots
|
|
456
|
+
- **Print media before PDF** — `emulateMedia({ media: 'print' })` to see what the PDF will look like
|
|
457
|
+
- **Video adds overhead** — only record when needed; tracing is lighter for debugging
|