@kamleshsk/claude-qa 1.0.1

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.
@@ -0,0 +1,388 @@
1
+ ---
2
+ name: playwright-cli
3
+ description: Automate browser interactions, test web pages and work with Playwright tests.
4
+ allowed-tools: Bash(playwright-cli:*) Bash(npx:*) Bash(npm:*)
5
+ ---
6
+
7
+ # Browser Automation with playwright-cli
8
+
9
+ ## Quick start
10
+
11
+ ```bash
12
+ # open new browser
13
+ playwright-cli open
14
+ # navigate to a page
15
+ playwright-cli goto https://playwright.dev
16
+ # interact with the page using refs from the snapshot
17
+ playwright-cli click e15
18
+ playwright-cli type "page.click"
19
+ playwright-cli press Enter
20
+ # take a screenshot (rarely used, as snapshot is more common)
21
+ playwright-cli screenshot
22
+ # close the browser
23
+ playwright-cli close
24
+ ```
25
+
26
+ ## Commands
27
+
28
+ ### Core
29
+
30
+ ```bash
31
+ playwright-cli open
32
+ # open and navigate right away
33
+ playwright-cli open https://example.com/
34
+ playwright-cli goto https://playwright.dev
35
+ playwright-cli type "search query"
36
+ playwright-cli click e3
37
+ playwright-cli dblclick e7
38
+ # --submit presses Enter after filling the element
39
+ playwright-cli fill e5 "user@example.com" --submit
40
+ playwright-cli drag e2 e8
41
+ # drop files or data onto an element (from outside the page)
42
+ playwright-cli drop e4 --path=./image.png
43
+ playwright-cli drop e4 --data="text/plain=hello world"
44
+ playwright-cli hover e4
45
+ playwright-cli select e9 "option-value"
46
+ playwright-cli upload ./document.pdf
47
+ playwright-cli check e12
48
+ playwright-cli uncheck e12
49
+ playwright-cli snapshot
50
+ playwright-cli eval "document.title"
51
+ playwright-cli eval "el => el.textContent" e5
52
+ # get element id, class, or any attribute not visible in the snapshot
53
+ playwright-cli eval "el => el.id" e5
54
+ playwright-cli eval "el => el.getAttribute('data-testid')" e5
55
+ playwright-cli dialog-accept
56
+ playwright-cli dialog-accept "confirmation text"
57
+ playwright-cli dialog-dismiss
58
+ playwright-cli resize 1920 1080
59
+ playwright-cli close
60
+ ```
61
+
62
+ ### Navigation
63
+
64
+ ```bash
65
+ playwright-cli go-back
66
+ playwright-cli go-forward
67
+ playwright-cli reload
68
+ ```
69
+
70
+ ### Keyboard
71
+
72
+ ```bash
73
+ playwright-cli press Enter
74
+ playwright-cli press ArrowDown
75
+ playwright-cli keydown Shift
76
+ playwright-cli keyup Shift
77
+ ```
78
+
79
+ ### Mouse
80
+
81
+ ```bash
82
+ playwright-cli mousemove 150 300
83
+ playwright-cli mousedown
84
+ playwright-cli mousedown right
85
+ playwright-cli mouseup
86
+ playwright-cli mouseup right
87
+ playwright-cli mousewheel 0 100
88
+ ```
89
+
90
+ ### Save as
91
+
92
+ ```bash
93
+ playwright-cli screenshot
94
+ playwright-cli screenshot e5
95
+ playwright-cli screenshot --filename=page.png
96
+ playwright-cli pdf --filename=page.pdf
97
+ ```
98
+
99
+ ### Tabs
100
+
101
+ ```bash
102
+ playwright-cli tab-list
103
+ playwright-cli tab-new
104
+ playwright-cli tab-new https://example.com/page
105
+ playwright-cli tab-close
106
+ playwright-cli tab-close 2
107
+ playwright-cli tab-select 0
108
+ ```
109
+
110
+ ### Storage
111
+
112
+ ```bash
113
+ playwright-cli state-save
114
+ playwright-cli state-save auth.json
115
+ playwright-cli state-load auth.json
116
+
117
+ # Cookies
118
+ playwright-cli cookie-list
119
+ playwright-cli cookie-list --domain=example.com
120
+ playwright-cli cookie-get session_id
121
+ playwright-cli cookie-set session_id abc123
122
+ playwright-cli cookie-set session_id abc123 --domain=example.com --httpOnly --secure
123
+ playwright-cli cookie-delete session_id
124
+ playwright-cli cookie-clear
125
+
126
+ # LocalStorage
127
+ playwright-cli localstorage-list
128
+ playwright-cli localstorage-get theme
129
+ playwright-cli localstorage-set theme dark
130
+ playwright-cli localstorage-delete theme
131
+ playwright-cli localstorage-clear
132
+
133
+ # SessionStorage
134
+ playwright-cli sessionstorage-list
135
+ playwright-cli sessionstorage-get step
136
+ playwright-cli sessionstorage-set step 3
137
+ playwright-cli sessionstorage-delete step
138
+ playwright-cli sessionstorage-clear
139
+ ```
140
+
141
+ ### Network
142
+
143
+ ```bash
144
+ playwright-cli route "**/*.jpg" --status=404
145
+ playwright-cli route "https://api.example.com/**" --body='{"mock": true}'
146
+ playwright-cli route-list
147
+ playwright-cli unroute "**/*.jpg"
148
+ playwright-cli unroute
149
+ ```
150
+
151
+ ### DevTools
152
+
153
+ ```bash
154
+ playwright-cli console
155
+ playwright-cli console warning
156
+ playwright-cli requests
157
+ playwright-cli request 5
158
+ playwright-cli run-code "async page => await page.context().grantPermissions(['geolocation'])"
159
+ playwright-cli run-code --filename=script.js
160
+ playwright-cli tracing-start
161
+ playwright-cli tracing-stop
162
+ playwright-cli video-start video.webm
163
+ playwright-cli video-chapter "Chapter Title" --description="Details" --duration=2000
164
+ playwright-cli video-stop
165
+
166
+ # launch the dashboard for UI review / design feedback — user annotates the page, you receive the annotated screenshot, snapshot, and notes
167
+ playwright-cli show --annotate
168
+
169
+ # generate a Playwright locator for an element from its ref or selector
170
+ playwright-cli generate-locator e5 --raw
171
+
172
+ # show a persistent highlight overlay for an element, optionally with a custom style
173
+ playwright-cli highlight e5
174
+ playwright-cli highlight e5 --style="outline: 3px dashed red"
175
+ # hide a single element highlight, or all page highlights when no target is given
176
+ playwright-cli highlight e5 --hide
177
+ playwright-cli highlight --hide
178
+ ```
179
+
180
+ ## Raw output
181
+
182
+ The global `--raw` option strips page status, generated code, and snapshot sections from the output, returning only the result value. Use it to pipe command output into other tools. Commands that don't produce output return nothing.
183
+
184
+ ```bash
185
+ playwright-cli --raw eval "JSON.stringify(performance.timing)" | jq '.loadEventEnd - .navigationStart'
186
+ playwright-cli --raw eval "JSON.stringify([...document.querySelectorAll('a')].map(a => a.href))" > links.json
187
+ playwright-cli --raw snapshot > before.yml
188
+ playwright-cli click e5
189
+ playwright-cli --raw snapshot > after.yml
190
+ diff before.yml after.yml
191
+ TOKEN=$(playwright-cli --raw cookie-get session_id)
192
+ playwright-cli --raw localstorage-get theme
193
+ ```
194
+
195
+ For structured output wrapping every reply as JSON, pass --json
196
+ ```bash
197
+ playwright-cli list --json
198
+ ```
199
+
200
+ ## Open parameters
201
+ ```bash
202
+ # Use specific browser when creating session
203
+ playwright-cli open --browser=chrome
204
+ playwright-cli open --browser=firefox
205
+ playwright-cli open --browser=webkit
206
+ playwright-cli open --browser=msedge
207
+
208
+ # Use persistent profile (by default profile is in-memory)
209
+ playwright-cli open --persistent
210
+ # Use persistent profile with custom directory
211
+ playwright-cli open --profile=/path/to/profile
212
+
213
+ # Connect to browser via Playwright Extension
214
+ playwright-cli attach --extension=chrome
215
+
216
+ # Connect to a running Chrome or Edge by channel name
217
+ playwright-cli attach --cdp=chrome
218
+ playwright-cli attach --cdp=msedge
219
+
220
+ # Connect to a running browser via CDP endpoint
221
+ playwright-cli attach --cdp=http://localhost:9222
222
+
223
+ # Start with config file
224
+ playwright-cli open --config=my-config.json
225
+
226
+ # Close the browser
227
+ playwright-cli close
228
+ # Detach from an attached browser (leaves the external browser running)
229
+ playwright-cli -s=msedge detach
230
+ # Delete user data for the default session
231
+ playwright-cli delete-data
232
+ ```
233
+
234
+ ## Snapshots
235
+
236
+ After each command, playwright-cli provides a snapshot of the current browser state.
237
+
238
+ ```bash
239
+ > playwright-cli goto https://example.com
240
+ ### Page
241
+ - Page URL: https://example.com/
242
+ - Page Title: Example Domain
243
+ ### Snapshot
244
+ [Snapshot](.playwright-cli/page-2026-02-14T19-22-42-679Z.yml)
245
+ ```
246
+
247
+ You can also take a snapshot on demand using `playwright-cli snapshot` command. All the options below can be combined as needed.
248
+
249
+ ```bash
250
+ # default - save to a file with timestamp-based name
251
+ playwright-cli snapshot
252
+
253
+ # save to file, use when snapshot is a part of the workflow result
254
+ playwright-cli snapshot --filename=after-click.yaml
255
+
256
+ # snapshot an element instead of the whole page
257
+ playwright-cli snapshot "#main"
258
+
259
+ # limit snapshot depth for efficiency, take a partial snapshot afterwards
260
+ playwright-cli snapshot --depth=4
261
+ playwright-cli snapshot e34
262
+
263
+ # include each element's bounding box as [box=x,y,width,height]
264
+ playwright-cli snapshot --boxes
265
+ ```
266
+
267
+ ## Targeting elements
268
+
269
+ By default, use refs from the snapshot to interact with page elements.
270
+
271
+ ```bash
272
+ # get snapshot with refs
273
+ playwright-cli snapshot
274
+
275
+ # interact using a ref
276
+ playwright-cli click e15
277
+ ```
278
+
279
+ You can also use css selectors or Playwright locators.
280
+
281
+ ```bash
282
+ # css selector
283
+ playwright-cli click "#main > button.submit"
284
+
285
+ # role locator
286
+ playwright-cli click "getByRole('button', { name: 'Submit' })"
287
+
288
+ # test id
289
+ playwright-cli click "getByTestId('submit-button')"
290
+ ```
291
+
292
+ ## Browser Sessions
293
+
294
+ ```bash
295
+ # create new browser session named "mysession" with persistent profile
296
+ playwright-cli -s=mysession open example.com --persistent
297
+ # same with manually specified profile directory (use when requested explicitly)
298
+ playwright-cli -s=mysession open example.com --profile=/path/to/profile
299
+ playwright-cli -s=mysession click e6
300
+ playwright-cli -s=mysession close # stop a named browser
301
+ playwright-cli -s=mysession delete-data # delete user data for persistent session
302
+
303
+ playwright-cli list
304
+ # Close all browsers
305
+ playwright-cli close-all
306
+ # Forcefully kill all browser processes
307
+ playwright-cli kill-all
308
+ ```
309
+
310
+ ## Installation
311
+
312
+ If global `playwright-cli` command is not available, try a local version via `npx playwright-cli`:
313
+
314
+ ```bash
315
+ npx --no-install playwright-cli --version
316
+ ```
317
+
318
+ When local version is available, use `npx playwright-cli` in all commands. Otherwise, install `playwright-cli` as a global command:
319
+
320
+ ```bash
321
+ npm install -g @playwright/cli@latest
322
+ ```
323
+
324
+ ## Example: Form submission
325
+
326
+ ```bash
327
+ playwright-cli open https://example.com/form
328
+ playwright-cli snapshot
329
+
330
+ playwright-cli fill e1 "user@example.com"
331
+ playwright-cli fill e2 "password123"
332
+ playwright-cli click e3
333
+ playwright-cli snapshot
334
+ playwright-cli close
335
+ ```
336
+
337
+ ## Example: Multi-tab workflow
338
+
339
+ ```bash
340
+ playwright-cli open https://example.com
341
+ playwright-cli tab-new https://example.com/other
342
+ playwright-cli tab-list
343
+ playwright-cli tab-select 0
344
+ playwright-cli snapshot
345
+ playwright-cli close
346
+ ```
347
+
348
+ ## Example: Debugging with DevTools
349
+
350
+ ```bash
351
+ playwright-cli open https://example.com
352
+ playwright-cli click e4
353
+ playwright-cli fill e7 "test"
354
+ playwright-cli console
355
+ playwright-cli requests
356
+ playwright-cli close
357
+ ```
358
+
359
+ ```bash
360
+ playwright-cli open https://example.com
361
+ playwright-cli tracing-start
362
+ playwright-cli click e4
363
+ playwright-cli fill e7 "test"
364
+ playwright-cli tracing-stop
365
+ playwright-cli close
366
+ ```
367
+
368
+ ## Example: Interactive session
369
+
370
+ Ask the user for UI review or design feedback. The user draws boxes on the live page and types comments; you receive the annotated screenshot, the snapshot of the marked region, and the user's notes. Use this whenever the user asks for "UI review", "design feedback", or to "ask the user what they think / want / mean":
371
+
372
+ ```bash
373
+ playwright-cli open https://example.com
374
+ playwright-cli show --annotate
375
+ ```
376
+
377
+ ## Specific tasks
378
+
379
+ * **Running and Debugging Playwright tests** [references/playwright-tests.md](references/playwright-tests.md)
380
+ * **Request mocking** [references/request-mocking.md](references/request-mocking.md)
381
+ * **Running Playwright code** [references/running-code.md](references/running-code.md)
382
+ * **Browser session management** [references/session-management.md](references/session-management.md)
383
+ * **Spec-driven testing (plan / generate / heal)** [references/spec-driven-testing.md](references/spec-driven-testing.md)
384
+ * **Storage state (cookies, localStorage)** [references/storage-state.md](references/storage-state.md)
385
+ * **Test generation** [references/test-generation.md](references/test-generation.md)
386
+ * **Tracing** [references/tracing.md](references/tracing.md)
387
+ * **Video recording** [references/video-recording.md](references/video-recording.md)
388
+ * **Inspecting element attributes** [references/element-attributes.md](references/element-attributes.md)
@@ -0,0 +1,23 @@
1
+ # Inspecting Element Attributes
2
+
3
+ When the snapshot doesn't show an element's `id`, `class`, `data-*` attributes, or other DOM properties, use `eval` to inspect them.
4
+
5
+ ## Examples
6
+
7
+ ```bash
8
+ playwright-cli snapshot
9
+ # snapshot shows a button as e7 but doesn't reveal its id or data attributes
10
+
11
+ # get the element's id
12
+ playwright-cli eval "el => el.id" e7
13
+
14
+ # get all CSS classes
15
+ playwright-cli eval "el => el.className" e7
16
+
17
+ # get a specific attribute
18
+ playwright-cli eval "el => el.getAttribute('data-testid')" e7
19
+ playwright-cli eval "el => el.getAttribute('aria-label')" e7
20
+
21
+ # get a computed style property
22
+ playwright-cli eval "el => getComputedStyle(el).display" e7
23
+ ```
@@ -0,0 +1,39 @@
1
+ # Running Playwright Tests
2
+
3
+ To run Playwright tests, use the `npx playwright test` command, or a package manager script. To avoid opening the interactive html report, use `PLAYWRIGHT_HTML_OPEN=never` environment variable.
4
+
5
+ ```bash
6
+ # Run all tests
7
+ PLAYWRIGHT_HTML_OPEN=never npx playwright test
8
+
9
+ # Run all tests through a custom npm script
10
+ PLAYWRIGHT_HTML_OPEN=never npm run special-test-command
11
+ ```
12
+
13
+ # Debugging Playwright Tests
14
+
15
+ To debug a failing Playwright test, run it with `--debug=cli` option. This command will pause the test at the start and print the debugging instructions.
16
+
17
+ **IMPORTANT**: run the command in the background and check the output until "Debugging Instructions" is printed. Make sure to stop the command after you have finished.
18
+
19
+ Once instructions containing a session name are printed, use `playwright-cli` to attach the session and explore the page.
20
+
21
+ ```bash
22
+ # Run the test
23
+ PLAYWRIGHT_HTML_OPEN=never npx playwright test --debug=cli
24
+ # ...
25
+ # ... debugging instructions for "tw-abcdef" session ...
26
+ # ...
27
+
28
+ # Attach to the test
29
+ playwright-cli attach tw-abcdef
30
+ ```
31
+
32
+ Keep the test running in the background while you explore and look for a fix.
33
+ The test is paused at the start, so you should step over or pause at a particular location
34
+ where the problem is most likely to be.
35
+
36
+ Every action you perform with `playwright-cli` generates corresponding Playwright TypeScript code.
37
+ This code appears in the output and can be copied directly into the test. Most of the time, a specific locator or an expectation should be updated, but it could also be a bug in the app. Use your judgement.
38
+
39
+ After fixing the test, stop the background test run. Rerun to check that test passes.
@@ -0,0 +1,87 @@
1
+ # Request Mocking
2
+
3
+ Intercept, mock, modify, and block network requests.
4
+
5
+ ## CLI Route Commands
6
+
7
+ ```bash
8
+ # Mock with custom status
9
+ playwright-cli route "**/*.jpg" --status=404
10
+
11
+ # Mock with JSON body
12
+ playwright-cli route "**/api/users" --body='[{"id":1,"name":"Alice"}]' --content-type=application/json
13
+
14
+ # Mock with custom headers
15
+ playwright-cli route "**/api/data" --body='{"ok":true}' --header="X-Custom: value"
16
+
17
+ # Remove headers from requests
18
+ playwright-cli route "**/*" --remove-header=cookie,authorization
19
+
20
+ # List active routes
21
+ playwright-cli route-list
22
+
23
+ # Remove a route or all routes
24
+ playwright-cli unroute "**/*.jpg"
25
+ playwright-cli unroute
26
+ ```
27
+
28
+ ## URL Patterns
29
+
30
+ ```
31
+ **/api/users - Exact path match
32
+ **/api/*/details - Wildcard in path
33
+ **/*.{png,jpg,jpeg} - Match file extensions
34
+ **/search?q=* - Match query parameters
35
+ ```
36
+
37
+ ## Advanced Mocking with run-code
38
+
39
+ For conditional responses, request body inspection, response modification, or delays:
40
+
41
+ ### Conditional Response Based on Request
42
+
43
+ ```bash
44
+ playwright-cli run-code "async page => {
45
+ await page.route('**/api/login', route => {
46
+ const body = route.request().postDataJSON();
47
+ if (body.username === 'admin') {
48
+ route.fulfill({ body: JSON.stringify({ token: 'mock-token' }) });
49
+ } else {
50
+ route.fulfill({ status: 401, body: JSON.stringify({ error: 'Invalid' }) });
51
+ }
52
+ });
53
+ }"
54
+ ```
55
+
56
+ ### Modify Real Response
57
+
58
+ ```bash
59
+ playwright-cli run-code "async page => {
60
+ await page.route('**/api/user', async route => {
61
+ const response = await route.fetch();
62
+ const json = await response.json();
63
+ json.isPremium = true;
64
+ await route.fulfill({ response, json });
65
+ });
66
+ }"
67
+ ```
68
+
69
+ ### Simulate Network Failures
70
+
71
+ ```bash
72
+ playwright-cli run-code "async page => {
73
+ await page.route('**/api/offline', route => route.abort('internetdisconnected'));
74
+ }"
75
+ # Options: connectionrefused, timedout, connectionreset, internetdisconnected
76
+ ```
77
+
78
+ ### Delayed Response
79
+
80
+ ```bash
81
+ playwright-cli run-code "async page => {
82
+ await page.route('**/api/slow', async route => {
83
+ await new Promise(r => setTimeout(r, 3000));
84
+ route.fulfill({ body: JSON.stringify({ data: 'loaded' }) });
85
+ });
86
+ }"
87
+ ```