@agent-smith/feat-frontend 0.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,404 @@
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
+ # open new browser in headed mode
15
+ playwright-cli open --headed
16
+ # navigate to a page
17
+ playwright-cli goto https://playwright.dev
18
+ # interact with the page using refs from the snapshot
19
+ playwright-cli click e15
20
+ playwright-cli type "page.click"
21
+ playwright-cli press Enter
22
+ # take a screenshot (rarely used, as snapshot is more common)
23
+ playwright-cli screenshot
24
+ # close the browser
25
+ playwright-cli close
26
+ ```
27
+
28
+ ## Commands
29
+
30
+ ### Core
31
+
32
+ ```bash
33
+ playwright-cli open
34
+ # open and navigate right away
35
+ playwright-cli open https://example.com/
36
+ playwright-cli goto https://playwright.dev
37
+ playwright-cli type "search query"
38
+ playwright-cli click e3
39
+ playwright-cli dblclick e7
40
+ # --submit presses Enter after filling the element
41
+ playwright-cli fill e5 "user@example.com" --submit
42
+ playwright-cli drag e2 e8
43
+ # drop files or data onto an element (from outside the page)
44
+ playwright-cli drop e4 --path=./image.png
45
+ playwright-cli drop e4 --data="text/plain=hello world"
46
+ playwright-cli hover e4
47
+ playwright-cli select e9 "option-value"
48
+ playwright-cli upload ./document.pdf
49
+ playwright-cli check e12
50
+ playwright-cli uncheck e12
51
+ playwright-cli snapshot
52
+ # search the snapshot for text or a regexp, returns matching nodes with surrounding context
53
+ playwright-cli find "Sign in"
54
+ playwright-cli find --regex "Sign (in|up)"
55
+ # wrap the regexp in slashes to add flags, e.g. /i for case-insensitive
56
+ playwright-cli find --regex "/sign (in|up)/i"
57
+ playwright-cli eval "document.title"
58
+ playwright-cli eval "el => el.textContent" e5
59
+ # get element id, class, or any attribute not visible in the snapshot
60
+ playwright-cli eval "el => el.id" e5
61
+ playwright-cli eval "el => el.getAttribute('data-testid')" e5
62
+ playwright-cli dialog-accept
63
+ playwright-cli dialog-accept "confirmation text"
64
+ playwright-cli dialog-dismiss
65
+ playwright-cli resize 1920 1080
66
+ playwright-cli close
67
+ ```
68
+
69
+ ### Navigation
70
+
71
+ ```bash
72
+ playwright-cli go-back
73
+ playwright-cli go-forward
74
+ playwright-cli reload
75
+ ```
76
+
77
+ ### Keyboard
78
+
79
+ ```bash
80
+ playwright-cli press Enter
81
+ playwright-cli press ArrowDown
82
+ playwright-cli keydown Shift
83
+ playwright-cli keyup Shift
84
+ ```
85
+
86
+ ### Mouse
87
+
88
+ ```bash
89
+ playwright-cli mousemove 150 300
90
+ playwright-cli mousedown
91
+ playwright-cli mousedown right
92
+ playwright-cli mouseup
93
+ playwright-cli mouseup right
94
+ playwright-cli mousewheel 0 100
95
+ ```
96
+
97
+ ### Save as
98
+
99
+ ```bash
100
+ playwright-cli screenshot
101
+ playwright-cli screenshot e5
102
+ playwright-cli screenshot --filename=/workspace/page.png
103
+ playwright-cli screenshot --hires
104
+ playwright-cli pdf --filename=/workspace/page.pdf
105
+ ```
106
+
107
+ ### Tabs
108
+
109
+ ```bash
110
+ playwright-cli tab-list
111
+ playwright-cli tab-new
112
+ playwright-cli tab-new https://example.com/page
113
+ playwright-cli tab-close
114
+ playwright-cli tab-close 2
115
+ playwright-cli tab-select 0
116
+ ```
117
+
118
+ ### Storage
119
+
120
+ ```bash
121
+ playwright-cli state-save
122
+ playwright-cli state-save auth.json
123
+ playwright-cli state-load auth.json
124
+
125
+ # Cookies
126
+ playwright-cli cookie-list
127
+ playwright-cli cookie-list --domain=example.com
128
+ playwright-cli cookie-get session_id
129
+ playwright-cli cookie-set session_id abc123
130
+ playwright-cli cookie-set session_id abc123 --domain=example.com --httpOnly --secure
131
+ playwright-cli cookie-delete session_id
132
+ playwright-cli cookie-clear
133
+
134
+ # LocalStorage
135
+ playwright-cli localstorage-list
136
+ playwright-cli localstorage-get theme
137
+ playwright-cli localstorage-set theme dark
138
+ playwright-cli localstorage-delete theme
139
+ playwright-cli localstorage-clear
140
+
141
+ # SessionStorage
142
+ playwright-cli sessionstorage-list
143
+ playwright-cli sessionstorage-get step
144
+ playwright-cli sessionstorage-set step 3
145
+ playwright-cli sessionstorage-delete step
146
+ playwright-cli sessionstorage-clear
147
+ ```
148
+
149
+ ### Network
150
+
151
+ ```bash
152
+ playwright-cli route "**/*.jpg" --status=404
153
+ playwright-cli route "https://api.example.com/**" --body='{"mock": true}'
154
+ playwright-cli route-list
155
+ playwright-cli unroute "**/*.jpg"
156
+ playwright-cli unroute
157
+ ```
158
+
159
+ ### DevTools
160
+
161
+ ```bash
162
+ playwright-cli console
163
+ playwright-cli console warning
164
+ playwright-cli requests
165
+ playwright-cli request 5
166
+ playwright-cli run-code "async page => await page.context().grantPermissions(['geolocation'])"
167
+ playwright-cli run-code --filename=/workspace/script.js
168
+ playwright-cli tracing-start
169
+ playwright-cli tracing-stop
170
+
171
+ # record user actions in the browser, print them as Playwright code on stop
172
+ playwright-cli recording-start
173
+ playwright-cli recording-stop
174
+
175
+ playwright-cli video-start video.webm
176
+ playwright-cli video-chapter "Chapter Title" --description="Details" --duration=2000
177
+ playwright-cli video-stop
178
+
179
+ # annotate each subsequent action (click, type, ...) with a callout naming the action and highlighting the target
180
+ playwright-cli video-show-actions --duration=600 --position=top-right
181
+ playwright-cli video-hide-actions
182
+
183
+ # launch the dashboard for UI review / design feedback — user annotates the page, you receive the annotated screenshot, snapshot, and notes
184
+ playwright-cli show --annotate
185
+
186
+ # generate a Playwright locator for an element from its ref or selector
187
+ playwright-cli generate-locator e5 --raw
188
+
189
+ # show a persistent highlight overlay for an element, optionally with a custom style
190
+ playwright-cli highlight e5
191
+ playwright-cli highlight e5 --style="outline: 3px dashed red"
192
+ # hide a single element highlight, or all page highlights when no target is given
193
+ playwright-cli highlight e5 --hide
194
+ playwright-cli highlight --hide
195
+ ```
196
+
197
+ ## Raw output
198
+
199
+ 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.
200
+
201
+ ```bash
202
+ playwright-cli --raw eval "JSON.stringify(performance.timing)" | jq '.loadEventEnd - .navigationStart'
203
+ playwright-cli --raw eval "JSON.stringify([...document.querySelectorAll('a')].map(a => a.href))" > links.json
204
+ playwright-cli --raw snapshot > before.yml
205
+ playwright-cli click e5
206
+ playwright-cli --raw snapshot > after.yml
207
+ diff before.yml after.yml
208
+ TOKEN=$(playwright-cli --raw cookie-get session_id)
209
+ playwright-cli --raw localstorage-get theme
210
+ ```
211
+
212
+ For structured output wrapping every reply as JSON, pass --json
213
+ ```bash
214
+ playwright-cli list --json
215
+ ```
216
+
217
+ ## Open parameters
218
+ ```bash
219
+ # Use specific browser when creating session
220
+ playwright-cli open --browser=chrome
221
+ playwright-cli open --browser=firefox
222
+ playwright-cli open --browser=webkit
223
+ playwright-cli open --browser=msedge
224
+
225
+ # Emulate a generic mobile device (Pixel 10 for Chromium, iPhone 17 for WebKit).
226
+ # Prefer this when a mobile layout is acceptable: mobile pages are usually
227
+ # lighter, so snapshots are smaller and cheaper.
228
+ playwright-cli open --mobile
229
+ playwright-cli open --device="iPhone 15"
230
+
231
+ # Open in headed mode
232
+ playwright-cli open --headed
233
+
234
+ # Use persistent profile (by default profile is in-memory)
235
+ playwright-cli open --persistent
236
+ # Use persistent profile with custom directory
237
+ playwright-cli open --profile=/path/to/profile
238
+
239
+ # Connect to browser via Playwright Extension
240
+ playwright-cli attach --extension=chrome
241
+
242
+ # Connect to a running Chrome or Edge by channel name
243
+ playwright-cli attach --cdp=chrome
244
+ playwright-cli attach --cdp=msedge
245
+
246
+ # Connect to a running browser via CDP endpoint
247
+ playwright-cli attach --cdp=http://localhost:9222
248
+
249
+ # Start with config file
250
+ playwright-cli open --config=my-config.json
251
+
252
+ # Close the browser
253
+ playwright-cli close
254
+ # Detach from an attached browser (leaves the external browser running)
255
+ playwright-cli -s=msedge detach
256
+ # Delete user data for the default session
257
+ playwright-cli delete-data
258
+ ```
259
+
260
+ ## Snapshots
261
+
262
+ After each command, playwright-cli provides a snapshot of the current browser state.
263
+
264
+ ```bash
265
+ > playwright-cli goto https://example.com
266
+ ### Page
267
+ - Page URL: https://example.com/
268
+ - Page Title: Example Domain
269
+ ### Snapshot
270
+ [Snapshot](.playwright-cli/page-2026-02-14T19-22-42-679Z.yml)
271
+ ```
272
+
273
+ You can also take a snapshot on demand using `playwright-cli snapshot` command. All the options below can be combined as needed.
274
+
275
+ ```bash
276
+ # default - save to a file with timestamp-based name
277
+ playwright-cli snapshot
278
+
279
+ # save to file, use when snapshot is a part of the workflow result
280
+ playwright-cli snapshot --filename=/workspace/after-click.yaml
281
+
282
+ # snapshot an element instead of the whole page
283
+ playwright-cli snapshot "#main"
284
+
285
+ # limit snapshot depth for efficiency, take a partial snapshot afterwards
286
+ playwright-cli snapshot --depth=4
287
+ playwright-cli snapshot e34
288
+
289
+ # include each element's bounding box as [box=x,y,width,height]
290
+ playwright-cli snapshot --boxes
291
+
292
+ # search a large snapshot instead of capturing it all — returns matching nodes
293
+ # with 3 lines of context around each match (like grep -C)
294
+ playwright-cli find "Add to cart"
295
+ playwright-cli find --regex "\\$[0-9]+\\.[0-9]{2}"
296
+ ```
297
+
298
+ ## Targeting elements
299
+
300
+ By default, use refs from the snapshot to interact with page elements.
301
+
302
+ ```bash
303
+ # get snapshot with refs
304
+ playwright-cli snapshot
305
+
306
+ # interact using a ref
307
+ playwright-cli click e15
308
+ ```
309
+
310
+ You can also use css selectors or Playwright locators.
311
+
312
+ ```bash
313
+ # css selector
314
+ playwright-cli click "#main > button.submit"
315
+
316
+ # role locator
317
+ playwright-cli click "getByRole('button', { name: 'Submit' })"
318
+
319
+ # test id
320
+ playwright-cli click "getByTestId('submit-button')"
321
+ ```
322
+
323
+ ## Browser Sessions
324
+
325
+ ```bash
326
+ # create new browser session named "mysession" with persistent profile
327
+ playwright-cli -s=mysession open example.com --persistent
328
+ # same with manually specified profile directory (use when requested explicitly)
329
+ playwright-cli -s=mysession open example.com --profile=/path/to/profile
330
+ playwright-cli -s=mysession click e6
331
+ playwright-cli -s=mysession close # stop a named browser
332
+ playwright-cli -s=mysession delete-data # delete user data for persistent session
333
+
334
+ playwright-cli list
335
+ # Close all browsers
336
+ playwright-cli close-all
337
+ # Forcefully kill all browser processes
338
+ playwright-cli kill-all
339
+ ```
340
+
341
+ ## Example: Form submission
342
+
343
+ ```bash
344
+ playwright-cli open https://example.com/form
345
+ playwright-cli snapshot
346
+
347
+ playwright-cli fill e1 "user@example.com"
348
+ playwright-cli fill e2 "password123"
349
+ playwright-cli click e3
350
+ playwright-cli snapshot
351
+ playwright-cli close
352
+ ```
353
+
354
+ ## Example: Multi-tab workflow
355
+
356
+ ```bash
357
+ playwright-cli open https://example.com
358
+ playwright-cli tab-new https://example.com/other
359
+ playwright-cli tab-list
360
+ playwright-cli tab-select 0
361
+ playwright-cli snapshot
362
+ playwright-cli close
363
+ ```
364
+
365
+ ## Example: Debugging with DevTools
366
+
367
+ ```bash
368
+ playwright-cli open https://example.com
369
+ playwright-cli click e4
370
+ playwright-cli fill e7 "test"
371
+ playwright-cli console
372
+ playwright-cli requests
373
+ playwright-cli close
374
+ ```
375
+
376
+ ```bash
377
+ playwright-cli open https://example.com
378
+ playwright-cli tracing-start
379
+ playwright-cli click e4
380
+ playwright-cli fill e7 "test"
381
+ playwright-cli tracing-stop
382
+ playwright-cli close
383
+ ```
384
+
385
+ ## Example: Interactive session
386
+
387
+ 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":
388
+
389
+ ```bash
390
+ playwright-cli open https://example.com
391
+ playwright-cli show --annotate
392
+ ```
393
+
394
+ ## Specific tasks
395
+
396
+ * **Running and Debugging Playwright tests** [references/playwright-tests.md](references/playwright-tests.md)
397
+ * **Request mocking** [references/request-mocking.md](references/request-mocking.md)
398
+ * **Running Playwright code** [references/running-code.md](references/running-code.md)
399
+ * **Browser session management** [references/session-management.md](references/session-management.md)
400
+ * **Storage state (cookies, localStorage)** [references/storage-state.md](references/storage-state.md)
401
+ * **Test generation (plan / generate / heal)** [references/test-generation.md](references/test-generation.md)
402
+ * **Tracing** [references/tracing.md](references/tracing.md)
403
+ * **Video recording** [references/video-recording.md](references/video-recording.md)
404
+ * **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
+ ```