@caddis/cli 0.0.0 → 0.1.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.
Files changed (153) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -1
  3. package/bundles/antigravity-plugin/agents/code-reviewer.md +47 -0
  4. package/bundles/antigravity-plugin/agents/preflight.md +53 -0
  5. package/bundles/antigravity-plugin/guard_agy.py +338 -0
  6. package/bundles/antigravity-plugin/hooks.json +36 -0
  7. package/bundles/antigravity-plugin/mcp_config.json +8 -0
  8. package/bundles/antigravity-plugin/mcp_ping_server.py +55 -0
  9. package/bundles/antigravity-plugin/plugin.json +5 -0
  10. package/bundles/antigravity-plugin/session_end_agy.py +57 -0
  11. package/bundles/antigravity-plugin/skills/_registry.md +115 -0
  12. package/bundles/antigravity-plugin/skills/add-rules/SKILL.md +45 -0
  13. package/bundles/antigravity-plugin/skills/api-design/SKILL.md +249 -0
  14. package/bundles/antigravity-plugin/skills/backend-development/SKILL.md +305 -0
  15. package/bundles/antigravity-plugin/skills/best-practices/SKILL.md +500 -0
  16. package/bundles/antigravity-plugin/skills/best-practices/agents/best-practices-referencer.md +263 -0
  17. package/bundles/antigravity-plugin/skills/best-practices/agents/codebase-context-builder.md +326 -0
  18. package/bundles/antigravity-plugin/skills/best-practices/agents/task-intent-analyzer.md +245 -0
  19. package/bundles/antigravity-plugin/skills/best-practices/references/anti-patterns.md +571 -0
  20. package/bundles/antigravity-plugin/skills/best-practices/references/before-after-examples.md +1114 -0
  21. package/bundles/antigravity-plugin/skills/best-practices/references/best-practices-guide.md +513 -0
  22. package/bundles/antigravity-plugin/skills/best-practices/references/common-workflows.md +692 -0
  23. package/bundles/antigravity-plugin/skills/best-practices/references/prompt-patterns.md +547 -0
  24. package/bundles/antigravity-plugin/skills/brainstorming/SKILL.md +57 -0
  25. package/bundles/antigravity-plugin/skills/ci-cd-pipeline/SKILL.md +315 -0
  26. package/bundles/antigravity-plugin/skills/code-documentation/SKILL.md +271 -0
  27. package/bundles/antigravity-plugin/skills/code-review/SKILL.md +122 -0
  28. package/bundles/antigravity-plugin/skills/codebase-audit/SKILL.md +204 -0
  29. package/bundles/antigravity-plugin/skills/context-curator/SKILL.md +157 -0
  30. package/bundles/antigravity-plugin/skills/cross-review/SKILL.md +40 -0
  31. package/bundles/antigravity-plugin/skills/css-architecture/SKILL.md +305 -0
  32. package/bundles/antigravity-plugin/skills/css-architecture/references/RESPONSIVE-DESIGN.md +604 -0
  33. package/bundles/antigravity-plugin/skills/database-design/SKILL.md +177 -0
  34. package/bundles/antigravity-plugin/skills/db-diagram/SKILL.md +148 -0
  35. package/bundles/antigravity-plugin/skills/db-diagram/scripts/sql_to_graph.py +1212 -0
  36. package/bundles/antigravity-plugin/skills/digress/SKILL.md +61 -0
  37. package/bundles/antigravity-plugin/skills/draw-io/SKILL.md +162 -0
  38. package/bundles/antigravity-plugin/skills/draw-io/references/aws-icons.md +677 -0
  39. package/bundles/antigravity-plugin/skills/draw-io/references/layout-guidelines.md +142 -0
  40. package/bundles/antigravity-plugin/skills/draw-io/references/troubleshooting.md +118 -0
  41. package/bundles/antigravity-plugin/skills/draw-io/references/workflows.md +103 -0
  42. package/bundles/antigravity-plugin/skills/draw-io/scripts/convert-drawio-to-png.sh +25 -0
  43. package/bundles/antigravity-plugin/skills/draw-io/scripts/find_aws_icon.py +79 -0
  44. package/bundles/antigravity-plugin/skills/error-handling/SKILL.md +260 -0
  45. package/bundles/antigravity-plugin/skills/excalidraw-db/SKILL.md +38 -0
  46. package/bundles/antigravity-plugin/skills/fastapi-dev/SKILL.md +300 -0
  47. package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +198 -0
  48. package/bundles/antigravity-plugin/skills/frontend-design/SKILL.md +193 -0
  49. package/bundles/antigravity-plugin/skills/frontend-design/references/my-tech-stack.md +127 -0
  50. package/bundles/antigravity-plugin/skills/gh-cli/SKILL.md +195 -0
  51. package/bundles/antigravity-plugin/skills/git-commit/SKILL.md +285 -0
  52. package/bundles/antigravity-plugin/skills/golden-plan/SKILL.md +577 -0
  53. package/bundles/antigravity-plugin/skills/handoff/SKILL.md +100 -0
  54. package/bundles/antigravity-plugin/skills/implement/SKILL.md +114 -0
  55. package/bundles/antigravity-plugin/skills/javascript-typescript/SKILL.md +142 -0
  56. package/bundles/antigravity-plugin/skills/kb/SKILL.md +60 -0
  57. package/bundles/antigravity-plugin/skills/mermaid-db/SKILL.md +33 -0
  58. package/bundles/antigravity-plugin/skills/mermaid-diagrams/SKILL.md +236 -0
  59. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/ENHANCEMENTS.md +264 -0
  60. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/MERMAID-SUMMARY.md +137 -0
  61. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/advanced-features.md +556 -0
  62. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/architecture-diagrams.md +192 -0
  63. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/c4-diagrams.md +410 -0
  64. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/class-diagrams.md +361 -0
  65. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/erd-diagrams.md +510 -0
  66. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/flowcharts.md +450 -0
  67. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/sequence-diagrams.md +394 -0
  68. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/troubleshooting.md +335 -0
  69. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/workflows.md +418 -0
  70. package/bundles/antigravity-plugin/skills/migrate-dir/SKILL.md +68 -0
  71. package/bundles/antigravity-plugin/skills/mockup/SKILL.md +242 -0
  72. package/bundles/antigravity-plugin/skills/particle-art/SKILL.md +243 -0
  73. package/bundles/antigravity-plugin/skills/particle-art/references/canvas-utils.ts +171 -0
  74. package/bundles/antigravity-plugin/skills/particle-art/references/dot-field.template.tsx +203 -0
  75. package/bundles/antigravity-plugin/skills/particle-art/references/flow-field.template.tsx +263 -0
  76. package/bundles/antigravity-plugin/skills/particle-art/references/node-shape.template.tsx +261 -0
  77. package/bundles/antigravity-plugin/skills/particle-art/references/shape-sampler.ts +281 -0
  78. package/bundles/antigravity-plugin/skills/particle-art/references/stipple-morph.template.tsx +167 -0
  79. package/bundles/antigravity-plugin/skills/particle-art/references/stipple.template.tsx +175 -0
  80. package/bundles/antigravity-plugin/skills/particle-art/references/trail-ghost.template.tsx +266 -0
  81. package/bundles/antigravity-plugin/skills/particle-art/references/usage-examples.md +320 -0
  82. package/bundles/antigravity-plugin/skills/playwright/API_REFERENCE.md +653 -0
  83. package/bundles/antigravity-plugin/skills/playwright/SKILL.md +454 -0
  84. package/bundles/antigravity-plugin/skills/playwright/lib/helpers.js +441 -0
  85. package/bundles/antigravity-plugin/skills/playwright/package.json +26 -0
  86. package/bundles/antigravity-plugin/skills/playwright/run.js +228 -0
  87. package/bundles/antigravity-plugin/skills/prd/SKILL.md +107 -0
  88. package/bundles/antigravity-plugin/skills/preflight/SKILL.md +435 -0
  89. package/bundles/antigravity-plugin/skills/python/SKILL.md +388 -0
  90. package/bundles/antigravity-plugin/skills/react-best-practices/SKILL.md +269 -0
  91. package/bundles/antigravity-plugin/skills/react-dev/README.md +404 -0
  92. package/bundles/antigravity-plugin/skills/react-dev/SKILL.md +459 -0
  93. package/bundles/antigravity-plugin/skills/react-dev/examples/generic-components.md +579 -0
  94. package/bundles/antigravity-plugin/skills/react-dev/examples/server-components.md +579 -0
  95. package/bundles/antigravity-plugin/skills/react-dev/references/event-handlers.md +574 -0
  96. package/bundles/antigravity-plugin/skills/react-dev/references/hooks.md +456 -0
  97. package/bundles/antigravity-plugin/skills/react-dev/references/react-19-patterns.md +638 -0
  98. package/bundles/antigravity-plugin/skills/react-dev/references/react-router.md +1002 -0
  99. package/bundles/antigravity-plugin/skills/react-dev/references/tanstack-router.md +587 -0
  100. package/bundles/antigravity-plugin/skills/refactoring/SKILL.md +486 -0
  101. package/bundles/antigravity-plugin/skills/resume/SKILL.md +36 -0
  102. package/bundles/antigravity-plugin/skills/security-review/SKILL.md +196 -0
  103. package/bundles/antigravity-plugin/skills/setup-project-ai/SKILL.md +61 -0
  104. package/bundles/antigravity-plugin/skills/ship/SKILL.md +107 -0
  105. package/bundles/antigravity-plugin/skills/ship-merge/SKILL.md +103 -0
  106. package/bundles/antigravity-plugin/skills/ship-pr/SKILL.md +102 -0
  107. package/bundles/antigravity-plugin/skills/skill-creator/LICENSE.txt +202 -0
  108. package/bundles/antigravity-plugin/skills/skill-creator/SKILL.md +491 -0
  109. package/bundles/antigravity-plugin/skills/skill-creator/agents/analyzer.md +274 -0
  110. package/bundles/antigravity-plugin/skills/skill-creator/agents/comparator.md +202 -0
  111. package/bundles/antigravity-plugin/skills/skill-creator/agents/grader.md +223 -0
  112. package/bundles/antigravity-plugin/skills/skill-creator/assets/eval_review.html +146 -0
  113. package/bundles/antigravity-plugin/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  114. package/bundles/antigravity-plugin/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  115. package/bundles/antigravity-plugin/skills/skill-creator/references/schemas.md +430 -0
  116. package/bundles/antigravity-plugin/skills/skill-creator/scripts/__init__.py +0 -0
  117. package/bundles/antigravity-plugin/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  118. package/bundles/antigravity-plugin/skills/skill-creator/scripts/generate_report.py +326 -0
  119. package/bundles/antigravity-plugin/skills/skill-creator/scripts/improve_description.py +247 -0
  120. package/bundles/antigravity-plugin/skills/skill-creator/scripts/package_skill.py +136 -0
  121. package/bundles/antigravity-plugin/skills/skill-creator/scripts/quick_validate.py +103 -0
  122. package/bundles/antigravity-plugin/skills/skill-creator/scripts/run_eval.py +310 -0
  123. package/bundles/antigravity-plugin/skills/skill-creator/scripts/run_loop.py +328 -0
  124. package/bundles/antigravity-plugin/skills/skill-creator/scripts/utils.py +47 -0
  125. package/bundles/antigravity-plugin/skills/sql/SKILL.md +321 -0
  126. package/bundles/antigravity-plugin/skills/tdd/SKILL.md +37 -0
  127. package/bundles/antigravity-plugin/skills/tdd-workflow/SKILL.md +188 -0
  128. package/bundles/antigravity-plugin/skills/technical-writing/SKILL.md +286 -0
  129. package/bundles/antigravity-plugin/skills/test-strategy/SKILL.md +155 -0
  130. package/bundles/antigravity-plugin/skills/ui-brief/SKILL.md +84 -0
  131. package/bundles/antigravity-plugin/skills/ui-review/SKILL.md +176 -0
  132. package/bundles/antigravity-plugin/skills/ui-review/references/framework-fixes.md +471 -0
  133. package/bundles/antigravity-plugin/skills/ui-review/references/visual-checklist.md +236 -0
  134. package/bundles/antigravity-plugin/skills/usage-review/SKILL.md +77 -0
  135. package/bundles/antigravity-plugin/skills/use-model/SKILL.md +64 -0
  136. package/bundles/antigravity-plugin/skills/using-git-worktrees/SKILL.md +217 -0
  137. package/bundles/antigravity-plugin/skills/version/SKILL.md +18 -0
  138. package/bundles/antigravity-plugin/skills/warm-editorial-ui/DESIGN_TOKENS.md +487 -0
  139. package/bundles/antigravity-plugin/skills/warm-editorial-ui/IMPLEMENTATION_GUIDE.md +177 -0
  140. package/bundles/antigravity-plugin/skills/warm-editorial-ui/SKILL.md +732 -0
  141. package/bundles/antigravity-plugin/skills/webapp-testing/LICENSE.txt +202 -0
  142. package/bundles/antigravity-plugin/skills/webapp-testing/SKILL.md +97 -0
  143. package/bundles/antigravity-plugin/skills/webapp-testing/examples/console_logging.py +35 -0
  144. package/bundles/antigravity-plugin/skills/webapp-testing/examples/element_discovery.py +40 -0
  145. package/bundles/antigravity-plugin/skills/webapp-testing/examples/static_html_automation.py +33 -0
  146. package/bundles/antigravity-plugin/skills/webapp-testing/scripts/with_server.py +106 -0
  147. package/bundles/antigravity-plugin/skills/windows-deployment/SKILL.md +880 -0
  148. package/bundles/antigravity-plugin/skills/writing-plans/SKILL.md +384 -0
  149. package/bundles/antigravity-plugin/statusline-command-agy.sh +91 -0
  150. package/bundles/antigravity-plugin/warm_start_agy.py +149 -0
  151. package/bundles/manifest.json +6 -0
  152. package/dist/cli.js +5363 -0
  153. package/package.json +61 -4
@@ -0,0 +1,653 @@
1
+ # Playwright Skill - Complete API Reference
2
+
3
+ This document contains the comprehensive Playwright API reference and advanced patterns. For quick-start execution patterns, see [SKILL.md](SKILL.md).
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation & Setup](#installation--setup)
8
+ - [Core Patterns](#core-patterns)
9
+ - [Selectors & Locators](#selectors--locators)
10
+ - [Common Actions](#common-actions)
11
+ - [Waiting Strategies](#waiting-strategies)
12
+ - [Assertions](#assertions)
13
+ - [Page Object Model](#page-object-model-pom)
14
+ - [Network & API Testing](#network--api-testing)
15
+ - [Authentication & Session Management](#authentication--session-management)
16
+ - [Visual Testing](#visual-testing)
17
+ - [Mobile Testing](#mobile-testing)
18
+ - [Debugging](#debugging)
19
+ - [Performance Testing](#performance-testing)
20
+ - [Parallel Execution](#parallel-execution)
21
+ - [Data-Driven Testing](#data-driven-testing)
22
+ - [Accessibility Testing](#accessibility-testing)
23
+ - [CI/CD Integration](#cicd-integration)
24
+ - [Best Practices](#best-practices)
25
+ - [Common Patterns & Solutions](#common-patterns--solutions)
26
+ - [Troubleshooting](#troubleshooting)
27
+
28
+ ## Installation & Setup
29
+
30
+ ### Prerequisites
31
+
32
+ Before using this skill, ensure Playwright is available:
33
+
34
+ ```bash
35
+ # Check if Playwright is installed
36
+ npm list playwright 2>/dev/null || echo "Playwright not installed"
37
+
38
+ # Install (if needed)
39
+ cd ~/.claude/skills/playwright-skill
40
+ npm run setup
41
+ ```
42
+
43
+ ### Basic Configuration
44
+
45
+ Create `playwright.config.ts`:
46
+
47
+ ```typescript
48
+ import { defineConfig, devices } from '@playwright/test';
49
+
50
+ export default defineConfig({
51
+ testDir: './tests',
52
+ fullyParallel: true,
53
+ forbidOnly: !!process.env.CI,
54
+ retries: process.env.CI ? 2 : 0,
55
+ workers: process.env.CI ? 1 : undefined,
56
+ reporter: 'html',
57
+ use: {
58
+ baseURL: 'http://localhost:3000',
59
+ trace: 'on-first-retry',
60
+ screenshot: 'only-on-failure',
61
+ video: 'retain-on-failure',
62
+ },
63
+ projects: [
64
+ {
65
+ name: 'chromium',
66
+ use: { ...devices['Desktop Chrome'] },
67
+ },
68
+ ],
69
+ webServer: {
70
+ command: 'npm run start',
71
+ url: 'http://localhost:3000',
72
+ reuseExistingServer: !process.env.CI,
73
+ },
74
+ });
75
+ ```
76
+
77
+ ## Core Patterns
78
+
79
+ ### Basic Browser Automation
80
+
81
+ ```javascript
82
+ const { chromium } = require('playwright');
83
+
84
+ (async () => {
85
+ // Launch browser
86
+ const browser = await chromium.launch({
87
+ headless: false, // Set to true for headless mode
88
+ slowMo: 50 // Slow down operations by 50ms
89
+ });
90
+
91
+ const context = await browser.newContext({
92
+ viewport: { width: 1280, height: 720 },
93
+ userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
94
+ });
95
+
96
+ const page = await context.newPage();
97
+
98
+ // Navigate
99
+ await page.goto('https://example.com', {
100
+ waitUntil: 'networkidle' // Wait for network to be idle
101
+ });
102
+
103
+ // Your automation here
104
+
105
+ await browser.close();
106
+ })();
107
+ ```
108
+
109
+ ### Test Structure
110
+
111
+ ```typescript
112
+ import { test, expect } from '@playwright/test';
113
+
114
+ test.describe('Feature Name', () => {
115
+ test.beforeEach(async ({ page }) => {
116
+ await page.goto('/');
117
+ });
118
+
119
+ test('should do something', async ({ page }) => {
120
+ // Arrange
121
+ const button = page.locator('button[data-testid="submit"]');
122
+
123
+ // Act
124
+ await button.click();
125
+
126
+ // Assert
127
+ await expect(page).toHaveURL('/success');
128
+ await expect(page.locator('.message')).toHaveText('Success!');
129
+ });
130
+ });
131
+ ```
132
+
133
+ ## Selectors & Locators
134
+
135
+ ### Best Practices for Selectors
136
+
137
+ ```javascript
138
+ // PREFERRED: Data attributes (most stable)
139
+ await page.locator('[data-testid="submit-button"]').click();
140
+ await page.locator('[data-cy="user-input"]').fill('text');
141
+
142
+ // GOOD: Role-based selectors (accessible)
143
+ await page.getByRole('button', { name: 'Submit' }).click();
144
+ await page.getByRole('textbox', { name: 'Email' }).fill('user@example.com');
145
+ await page.getByRole('heading', { level: 1 }).click();
146
+
147
+ // GOOD: Text content (for unique text)
148
+ await page.getByText('Sign in').click();
149
+ await page.getByText(/welcome back/i).click();
150
+
151
+ // OK: Semantic HTML
152
+ await page.locator('button[type="submit"]').click();
153
+ await page.locator('input[name="email"]').fill('test@test.com');
154
+
155
+ // AVOID: Classes and IDs (can change frequently)
156
+ await page.locator('.btn-primary').click(); // Avoid
157
+ await page.locator('#submit').click(); // Avoid
158
+
159
+ // LAST RESORT: Complex CSS/XPath
160
+ await page.locator('div.container > form > button').click(); // Fragile
161
+ ```
162
+
163
+ ### Advanced Locator Patterns
164
+
165
+ ```javascript
166
+ // Filter and chain locators
167
+ const row = page.locator('tr').filter({ hasText: 'John Doe' });
168
+ await row.locator('button').click();
169
+
170
+ // Nth element
171
+ await page.locator('button').nth(2).click();
172
+
173
+ // Combining conditions
174
+ await page.locator('button').and(page.locator('[disabled]')).count();
175
+
176
+ // Parent/child navigation
177
+ const cell = page.locator('td').filter({ hasText: 'Active' });
178
+ const row = cell.locator('..');
179
+ await row.locator('button.edit').click();
180
+ ```
181
+
182
+ ## Common Actions
183
+
184
+ ### Form Interactions
185
+
186
+ ```javascript
187
+ // Text input
188
+ await page.getByLabel('Email').fill('user@example.com');
189
+ await page.getByPlaceholder('Enter your name').fill('John Doe');
190
+
191
+ // Clear and type
192
+ await page.locator('#username').clear();
193
+ await page.locator('#username').type('newuser', { delay: 100 });
194
+
195
+ // Checkbox
196
+ await page.getByLabel('I agree').check();
197
+ await page.getByLabel('Subscribe').uncheck();
198
+
199
+ // Radio button
200
+ await page.getByLabel('Option 2').check();
201
+
202
+ // Select dropdown
203
+ await page.selectOption('select#country', 'usa');
204
+ await page.selectOption('select#country', { label: 'United States' });
205
+ await page.selectOption('select#country', { index: 2 });
206
+
207
+ // Multi-select
208
+ await page.selectOption('select#colors', ['red', 'blue', 'green']);
209
+
210
+ // File upload
211
+ await page.setInputFiles('input[type="file"]', 'path/to/file.pdf');
212
+ await page.setInputFiles('input[type="file"]', [
213
+ 'file1.pdf',
214
+ 'file2.pdf'
215
+ ]);
216
+ ```
217
+
218
+ ### Mouse Actions
219
+
220
+ ```javascript
221
+ // Click variations
222
+ await page.click('button'); // Left click
223
+ await page.click('button', { button: 'right' }); // Right click
224
+ await page.dblclick('button'); // Double click
225
+ await page.click('button', { position: { x: 10, y: 10 } }); // Click at position
226
+
227
+ // Hover
228
+ await page.hover('.menu-item');
229
+
230
+ // Drag and drop
231
+ await page.dragAndDrop('#source', '#target');
232
+
233
+ // Manual drag
234
+ await page.locator('#source').hover();
235
+ await page.mouse.down();
236
+ await page.locator('#target').hover();
237
+ await page.mouse.up();
238
+ ```
239
+
240
+ ### Keyboard Actions
241
+
242
+ ```javascript
243
+ // Type with delay
244
+ await page.keyboard.type('Hello World', { delay: 100 });
245
+
246
+ // Key combinations
247
+ await page.keyboard.press('Control+A');
248
+ await page.keyboard.press('Control+C');
249
+ await page.keyboard.press('Control+V');
250
+
251
+ // Special keys
252
+ await page.keyboard.press('Enter');
253
+ await page.keyboard.press('Tab');
254
+ await page.keyboard.press('Escape');
255
+ await page.keyboard.press('ArrowDown');
256
+ ```
257
+
258
+ ## Waiting Strategies
259
+
260
+ ### Smart Waiting
261
+
262
+ ```javascript
263
+ // Wait for element states
264
+ await page.locator('button').waitFor({ state: 'visible' });
265
+ await page.locator('.spinner').waitFor({ state: 'hidden' });
266
+ await page.locator('button').waitFor({ state: 'attached' });
267
+ await page.locator('button').waitFor({ state: 'detached' });
268
+
269
+ // Wait for specific conditions
270
+ await page.waitForURL('**/success');
271
+ await page.waitForURL(url => url.pathname === '/dashboard');
272
+
273
+ // Wait for network
274
+ await page.waitForLoadState('networkidle');
275
+ await page.waitForLoadState('domcontentloaded');
276
+
277
+ // Wait for function
278
+ await page.waitForFunction(() => document.querySelector('.loaded'));
279
+ await page.waitForFunction(
280
+ text => document.body.innerText.includes(text),
281
+ 'Content loaded'
282
+ );
283
+
284
+ // Wait for response
285
+ const responsePromise = page.waitForResponse('**/api/users');
286
+ await page.click('button#load-users');
287
+ const response = await responsePromise;
288
+
289
+ // Wait for request
290
+ await page.waitForRequest(request =>
291
+ request.url().includes('/api/') && request.method() === 'POST'
292
+ );
293
+
294
+ // Custom timeout
295
+ await page.locator('.slow-element').waitFor({
296
+ state: 'visible',
297
+ timeout: 10000 // 10 seconds
298
+ });
299
+ ```
300
+
301
+ ## Assertions
302
+
303
+ ### Common Assertions
304
+
305
+ ```javascript
306
+ import { expect } from '@playwright/test';
307
+
308
+ // Page assertions
309
+ await expect(page).toHaveTitle('My App');
310
+ await expect(page).toHaveURL('https://example.com/dashboard');
311
+ await expect(page).toHaveURL(/.*dashboard/);
312
+
313
+ // Element visibility
314
+ await expect(page.locator('.message')).toBeVisible();
315
+ await expect(page.locator('.spinner')).toBeHidden();
316
+ await expect(page.locator('button')).toBeEnabled();
317
+ await expect(page.locator('input')).toBeDisabled();
318
+
319
+ // Text content
320
+ await expect(page.locator('h1')).toHaveText('Welcome');
321
+ await expect(page.locator('.message')).toContainText('success');
322
+ await expect(page.locator('.items')).toHaveText(['Item 1', 'Item 2']);
323
+
324
+ // Input values
325
+ await expect(page.locator('input')).toHaveValue('test@example.com');
326
+ await expect(page.locator('input')).toBeEmpty();
327
+
328
+ // Attributes
329
+ await expect(page.locator('button')).toHaveAttribute('type', 'submit');
330
+ await expect(page.locator('img')).toHaveAttribute('src', /.*\.png/);
331
+
332
+ // CSS properties
333
+ await expect(page.locator('.error')).toHaveCSS('color', 'rgb(255, 0, 0)');
334
+
335
+ // Count
336
+ await expect(page.locator('.item')).toHaveCount(5);
337
+
338
+ // Checkbox/Radio state
339
+ await expect(page.locator('input[type="checkbox"]')).toBeChecked();
340
+ ```
341
+
342
+ ## Page Object Model (POM)
343
+
344
+ ### Basic Page Object
345
+
346
+ ```javascript
347
+ // pages/LoginPage.js
348
+ class LoginPage {
349
+ constructor(page) {
350
+ this.page = page;
351
+ this.usernameInput = page.locator('input[name="username"]');
352
+ this.passwordInput = page.locator('input[name="password"]');
353
+ this.submitButton = page.locator('button[type="submit"]');
354
+ this.errorMessage = page.locator('.error-message');
355
+ }
356
+
357
+ async navigate() {
358
+ await this.page.goto('/login');
359
+ }
360
+
361
+ async login(username, password) {
362
+ await this.usernameInput.fill(username);
363
+ await this.passwordInput.fill(password);
364
+ await this.submitButton.click();
365
+ }
366
+
367
+ async getErrorMessage() {
368
+ return await this.errorMessage.textContent();
369
+ }
370
+ }
371
+
372
+ // Usage in test
373
+ test('login with valid credentials', async ({ page }) => {
374
+ const loginPage = new LoginPage(page);
375
+ await loginPage.navigate();
376
+ await loginPage.login('user@example.com', 'password123');
377
+ await expect(page).toHaveURL('/dashboard');
378
+ });
379
+ ```
380
+
381
+ ## Network & API Testing
382
+
383
+ ### Intercepting Requests
384
+
385
+ ```javascript
386
+ // Mock API responses
387
+ await page.route('**/api/users', route => {
388
+ route.fulfill({
389
+ status: 200,
390
+ contentType: 'application/json',
391
+ body: JSON.stringify([
392
+ { id: 1, name: 'John' },
393
+ { id: 2, name: 'Jane' }
394
+ ])
395
+ });
396
+ });
397
+
398
+ // Modify requests
399
+ await page.route('**/api/**', route => {
400
+ const headers = {
401
+ ...route.request().headers(),
402
+ 'X-Custom-Header': 'value'
403
+ };
404
+ route.continue({ headers });
405
+ });
406
+
407
+ // Block resources
408
+ await page.route('**/*.{png,jpg,jpeg,gif}', route => route.abort());
409
+ ```
410
+
411
+ ### Custom Headers via Environment Variables
412
+
413
+ The skill supports automatic header injection via environment variables:
414
+
415
+ ```bash
416
+ # Single header (simple)
417
+ PW_HEADER_NAME=X-Automated-By PW_HEADER_VALUE=playwright-skill
418
+
419
+ # Multiple headers (JSON)
420
+ PW_EXTRA_HEADERS='{"X-Automated-By":"playwright-skill","X-Request-ID":"123"}'
421
+ ```
422
+
423
+ These headers are automatically applied to all requests when using:
424
+ - `helpers.createContext(browser)` - headers merged automatically
425
+ - `getContextOptionsWithHeaders(options)` - utility injected by run.js wrapper
426
+
427
+ **Precedence (highest to lowest):**
428
+ 1. Headers passed directly in `options.extraHTTPHeaders`
429
+ 2. Environment variable headers
430
+ 3. Playwright defaults
431
+
432
+ **Use case:** Identify automated traffic so your backend can return LLM-optimized responses (e.g., plain text errors instead of styled HTML).
433
+
434
+ ## Visual Testing
435
+
436
+ ### Screenshots
437
+
438
+ ```javascript
439
+ // Full page screenshot
440
+ await page.screenshot({
441
+ path: 'screenshot.png',
442
+ fullPage: true
443
+ });
444
+
445
+ // Element screenshot
446
+ await page.locator('.chart').screenshot({
447
+ path: 'chart.png'
448
+ });
449
+
450
+ // Visual comparison
451
+ await expect(page).toHaveScreenshot('homepage.png');
452
+ ```
453
+
454
+ ## Mobile Testing
455
+
456
+ ```javascript
457
+ // Device emulation
458
+ const { devices } = require('playwright');
459
+ const iPhone = devices['iPhone 12'];
460
+
461
+ const context = await browser.newContext({
462
+ ...iPhone,
463
+ locale: 'en-US',
464
+ permissions: ['geolocation'],
465
+ geolocation: { latitude: 37.7749, longitude: -122.4194 }
466
+ });
467
+ ```
468
+
469
+ ## Debugging
470
+
471
+ ### Debug Mode
472
+
473
+ ```bash
474
+ # Run with inspector
475
+ npx playwright test --debug
476
+
477
+ # Headed mode
478
+ npx playwright test --headed
479
+
480
+ # Slow motion
481
+ npx playwright test --headed --slowmo=1000
482
+ ```
483
+
484
+ ### In-Code Debugging
485
+
486
+ ```javascript
487
+ // Pause execution
488
+ await page.pause();
489
+
490
+ // Console logs
491
+ page.on('console', msg => console.log('Browser log:', msg.text()));
492
+ page.on('pageerror', error => console.log('Page error:', error));
493
+ ```
494
+
495
+ ## Performance Testing
496
+
497
+ ```javascript
498
+ // Measure page load time
499
+ const startTime = Date.now();
500
+ await page.goto('https://example.com');
501
+ const loadTime = Date.now() - startTime;
502
+ console.log(`Page loaded in ${loadTime}ms`);
503
+ ```
504
+
505
+ ## Parallel Execution
506
+
507
+ ```javascript
508
+ // Run tests in parallel
509
+ test.describe.parallel('Parallel suite', () => {
510
+ test('test 1', async ({ page }) => {
511
+ // Runs in parallel with test 2
512
+ });
513
+
514
+ test('test 2', async ({ page }) => {
515
+ // Runs in parallel with test 1
516
+ });
517
+ });
518
+ ```
519
+
520
+ ## Data-Driven Testing
521
+
522
+ ```javascript
523
+ // Parameterized tests
524
+ const testData = [
525
+ { username: 'user1', password: 'pass1', expected: 'Welcome user1' },
526
+ { username: 'user2', password: 'pass2', expected: 'Welcome user2' },
527
+ ];
528
+
529
+ testData.forEach(({ username, password, expected }) => {
530
+ test(`login with ${username}`, async ({ page }) => {
531
+ await page.goto('/login');
532
+ await page.fill('#username', username);
533
+ await page.fill('#password', password);
534
+ await page.click('button[type="submit"]');
535
+ await expect(page.locator('.message')).toHaveText(expected);
536
+ });
537
+ });
538
+ ```
539
+
540
+ ## Accessibility Testing
541
+
542
+ ```javascript
543
+ import { injectAxe, checkA11y } from 'axe-playwright';
544
+
545
+ test('accessibility check', async ({ page }) => {
546
+ await page.goto('/');
547
+ await injectAxe(page);
548
+ await checkA11y(page);
549
+ });
550
+ ```
551
+
552
+ ## CI/CD Integration
553
+
554
+ ### GitHub Actions
555
+
556
+ ```yaml
557
+ name: Playwright Tests
558
+ on:
559
+ push:
560
+ branches: [main, master]
561
+ jobs:
562
+ test:
563
+ runs-on: ubuntu-latest
564
+ steps:
565
+ - uses: actions/checkout@v3
566
+ - uses: actions/setup-node@v3
567
+ - name: Install dependencies
568
+ run: npm ci
569
+ - name: Install Playwright Browsers
570
+ run: npx playwright install --with-deps
571
+ - name: Run tests
572
+ run: npx playwright test
573
+ ```
574
+
575
+ ## Best Practices
576
+
577
+ 1. **Test Organization** - Use descriptive test names, group related tests
578
+ 2. **Selector Strategy** - Prefer data-testid attributes, use role-based selectors
579
+ 3. **Waiting** - Use Playwright's auto-waiting, avoid hard-coded delays
580
+ 4. **Error Handling** - Add proper error messages, take screenshots on failure
581
+ 5. **Performance** - Run tests in parallel, reuse authentication state
582
+
583
+ ## Common Patterns & Solutions
584
+
585
+ ### Handling Popups
586
+
587
+ ```javascript
588
+ const [popup] = await Promise.all([
589
+ page.waitForEvent('popup'),
590
+ page.click('button.open-popup')
591
+ ]);
592
+ await popup.waitForLoadState();
593
+ ```
594
+
595
+ ### File Downloads
596
+
597
+ ```javascript
598
+ const [download] = await Promise.all([
599
+ page.waitForEvent('download'),
600
+ page.click('button.download')
601
+ ]);
602
+ await download.saveAs(`./downloads/${download.suggestedFilename()}`);
603
+ ```
604
+
605
+ ### iFrames
606
+
607
+ ```javascript
608
+ const frame = page.frameLocator('#my-iframe');
609
+ await frame.locator('button').click();
610
+ ```
611
+
612
+ ### Infinite Scroll
613
+
614
+ ```javascript
615
+ async function scrollToBottom(page) {
616
+ await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
617
+ await page.waitForTimeout(500);
618
+ }
619
+ ```
620
+
621
+ ## Troubleshooting
622
+
623
+ ### Common Issues
624
+
625
+ 1. **Element not found** - Check if element is in iframe, verify visibility
626
+ 2. **Timeout errors** - Increase timeout, check network conditions
627
+ 3. **Flaky tests** - Use proper waiting strategies, mock external dependencies
628
+ 4. **Authentication issues** - Verify auth state is properly saved
629
+
630
+ ## Quick Reference Commands
631
+
632
+ ```bash
633
+ # Run tests
634
+ npx playwright test
635
+
636
+ # Run in headed mode
637
+ npx playwright test --headed
638
+
639
+ # Debug tests
640
+ npx playwright test --debug
641
+
642
+ # Generate code
643
+ npx playwright codegen https://example.com
644
+
645
+ # Show report
646
+ npx playwright show-report
647
+ ```
648
+
649
+ ## Additional Resources
650
+
651
+ - [Playwright Documentation](https://playwright.dev/docs/intro)
652
+ - [API Reference](https://playwright.dev/docs/api/class-playwright)
653
+ - [Best Practices](https://playwright.dev/docs/best-practices)