@bastani/atomic 0.8.31-alpha.1 → 0.8.31-alpha.2

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 (145) hide show
  1. package/CHANGELOG.md +14 -3
  2. package/README.md +12 -10
  3. package/dist/builtin/cursor/CHANGELOG.md +1 -1
  4. package/dist/builtin/cursor/package.json +2 -2
  5. package/dist/builtin/intercom/CHANGELOG.md +1 -1
  6. package/dist/builtin/intercom/package.json +2 -2
  7. package/dist/builtin/mcp/CHANGELOG.md +1 -1
  8. package/dist/builtin/mcp/package.json +3 -3
  9. package/dist/builtin/subagents/CHANGELOG.md +10 -1
  10. package/dist/builtin/subagents/agents/codebase-online-researcher.md +8 -8
  11. package/dist/builtin/subagents/agents/debugger.md +6 -6
  12. package/dist/builtin/subagents/package.json +4 -4
  13. package/dist/builtin/subagents/skills/effective-liteparse/SKILL.md +118 -0
  14. package/dist/builtin/subagents/skills/effective-liteparse/scripts/search.py +128 -0
  15. package/dist/builtin/subagents/skills/playwright-cli/SKILL.md +404 -0
  16. package/dist/builtin/subagents/skills/playwright-cli/references/element-attributes.md +23 -0
  17. package/dist/builtin/subagents/skills/playwright-cli/references/playwright-tests.md +39 -0
  18. package/dist/builtin/subagents/skills/playwright-cli/references/request-mocking.md +87 -0
  19. package/dist/builtin/subagents/skills/playwright-cli/references/running-code.md +241 -0
  20. package/dist/builtin/subagents/skills/playwright-cli/references/session-management.md +225 -0
  21. package/dist/builtin/subagents/skills/playwright-cli/references/spec-driven-testing.md +305 -0
  22. package/dist/builtin/subagents/skills/playwright-cli/references/storage-state.md +275 -0
  23. package/dist/builtin/subagents/skills/playwright-cli/references/test-generation.md +134 -0
  24. package/dist/builtin/subagents/skills/playwright-cli/references/tracing.md +139 -0
  25. package/dist/builtin/subagents/skills/playwright-cli/references/video-recording.md +143 -0
  26. package/dist/builtin/web-access/CHANGELOG.md +1 -1
  27. package/dist/builtin/web-access/package.json +2 -2
  28. package/dist/builtin/workflows/CHANGELOG.md +7 -1
  29. package/dist/builtin/workflows/README.md +4 -4
  30. package/dist/builtin/workflows/builtin/open-claude-design.ts +59 -56
  31. package/dist/builtin/workflows/builtin/ralph.ts +56 -3
  32. package/dist/builtin/workflows/builtin/shared-prompts.ts +1 -1
  33. package/dist/builtin/workflows/package.json +2 -2
  34. package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
  35. package/dist/cli/args.d.ts.map +1 -1
  36. package/dist/cli/args.js +1 -1
  37. package/dist/cli/args.js.map +1 -1
  38. package/dist/core/agent-session.d.ts +1 -0
  39. package/dist/core/agent-session.d.ts.map +1 -1
  40. package/dist/core/agent-session.js +38 -18
  41. package/dist/core/agent-session.js.map +1 -1
  42. package/dist/core/context-window.d.ts +11 -1
  43. package/dist/core/context-window.d.ts.map +1 -1
  44. package/dist/core/context-window.js +19 -6
  45. package/dist/core/context-window.js.map +1 -1
  46. package/dist/core/copilot-model-catalog.d.ts +19 -16
  47. package/dist/core/copilot-model-catalog.d.ts.map +1 -1
  48. package/dist/core/copilot-model-catalog.js +14 -11
  49. package/dist/core/copilot-model-catalog.js.map +1 -1
  50. package/dist/core/project-trust.d.ts.map +1 -1
  51. package/dist/core/project-trust.js +2 -1
  52. package/dist/core/project-trust.js.map +1 -1
  53. package/dist/core/sdk.d.ts.map +1 -1
  54. package/dist/core/sdk.js +18 -7
  55. package/dist/core/sdk.js.map +1 -1
  56. package/dist/core/settings-manager.d.ts +11 -2
  57. package/dist/core/settings-manager.d.ts.map +1 -1
  58. package/dist/core/settings-manager.js +62 -8
  59. package/dist/core/settings-manager.js.map +1 -1
  60. package/dist/core/system-prompt.d.ts.map +1 -1
  61. package/dist/core/system-prompt.js +1 -0
  62. package/dist/core/system-prompt.js.map +1 -1
  63. package/dist/core/tools/edit-diff.d.ts +1 -2
  64. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  65. package/dist/core/tools/edit-diff.js +1 -2
  66. package/dist/core/tools/edit-diff.js.map +1 -1
  67. package/dist/index.d.ts +2 -1
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +1 -0
  70. package/dist/index.js.map +1 -1
  71. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  72. package/dist/modes/interactive/components/config-selector.js +5 -7
  73. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  74. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  75. package/dist/modes/interactive/components/model-selector.js +2 -1
  76. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  77. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  78. package/dist/modes/interactive/components/scoped-models-selector.js +4 -1
  79. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  80. package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
  81. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  82. package/dist/modes/interactive/components/settings-selector.js +165 -15
  83. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  84. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  85. package/dist/modes/interactive/components/tree-selector.js +44 -4
  86. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  87. package/dist/modes/interactive/interactive-mode.d.ts +1 -1
  88. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  89. package/dist/modes/interactive/interactive-mode.js +24 -54
  90. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  91. package/dist/modes/interactive/model-search.d.ts +7 -0
  92. package/dist/modes/interactive/model-search.d.ts.map +1 -0
  93. package/dist/modes/interactive/model-search.js +6 -0
  94. package/dist/modes/interactive/model-search.js.map +1 -0
  95. package/dist/modes/interactive/theme/theme-controller.d.ts +30 -0
  96. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
  97. package/dist/modes/interactive/theme/theme-controller.js +108 -0
  98. package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
  99. package/dist/modes/interactive/theme/theme-schema.json +2 -1
  100. package/dist/modes/interactive/theme/theme.d.ts +5 -0
  101. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  102. package/dist/modes/interactive/theme/theme.js +70 -29
  103. package/dist/modes/interactive/theme/theme.js.map +1 -1
  104. package/dist/modes/rpc/rpc-client.d.ts +1 -1
  105. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  106. package/dist/modes/rpc/rpc-client.js +1 -1
  107. package/dist/modes/rpc/rpc-client.js.map +1 -1
  108. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  109. package/dist/modes/rpc/rpc-mode.js +1 -1
  110. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  111. package/dist/package-manager-cli.d.ts.map +1 -1
  112. package/dist/package-manager-cli.js +39 -9
  113. package/dist/package-manager-cli.js.map +1 -1
  114. package/docs/extensions.md +21 -0
  115. package/docs/models.md +3 -3
  116. package/docs/packages.md +13 -9
  117. package/docs/providers.md +2 -2
  118. package/docs/quickstart.md +14 -0
  119. package/docs/rpc.md +3 -3
  120. package/docs/sdk.md +15 -11
  121. package/docs/session-format.md +1 -1
  122. package/docs/settings.md +8 -3
  123. package/docs/themes.md +3 -1
  124. package/docs/tui.md +1 -1
  125. package/docs/usage.md +12 -9
  126. package/docs/workflows.md +9 -7
  127. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  128. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  129. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  130. package/examples/extensions/gondolin/package-lock.json +2 -2
  131. package/examples/extensions/gondolin/package.json +1 -1
  132. package/examples/extensions/preset.ts +10 -4
  133. package/examples/extensions/provider-payload.ts +5 -5
  134. package/examples/extensions/sandbox/index.ts +2 -2
  135. package/examples/extensions/sandbox/package-lock.json +3 -3
  136. package/examples/extensions/sandbox/package.json +2 -2
  137. package/examples/extensions/subagent/agents.ts +2 -2
  138. package/examples/extensions/subagent/index.ts +4 -2
  139. package/examples/extensions/with-deps/package-lock.json +2 -2
  140. package/examples/extensions/with-deps/package.json +1 -1
  141. package/package.json +5 -5
  142. package/dist/builtin/subagents/skills/browser/EXAMPLES.md +0 -151
  143. package/dist/builtin/subagents/skills/browser/LICENSE.txt +0 -21
  144. package/dist/builtin/subagents/skills/browser/REFERENCE.md +0 -451
  145. package/dist/builtin/subagents/skills/browser/SKILL.md +0 -170
@@ -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
+ # 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
+ # annotate each subsequent action (click, type, ...) with a callout naming the action and highlighting the target
167
+ playwright-cli video-show-actions --duration=600 --position=top-right
168
+ playwright-cli video-hide-actions
169
+
170
+ # launch the dashboard for UI review / design feedback — user annotates the page, you receive the annotated screenshot, snapshot, and notes
171
+ playwright-cli show --annotate
172
+
173
+ # generate a Playwright locator for an element from its ref or selector
174
+ playwright-cli generate-locator e5 --raw
175
+
176
+ # show a persistent highlight overlay for an element, optionally with a custom style
177
+ playwright-cli highlight e5
178
+ playwright-cli highlight e5 --style="outline: 3px dashed red"
179
+ # hide a single element highlight, or all page highlights when no target is given
180
+ playwright-cli highlight e5 --hide
181
+ playwright-cli highlight --hide
182
+ ```
183
+
184
+ ## Raw output
185
+
186
+ 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.
187
+
188
+ ```bash
189
+ playwright-cli --raw eval "JSON.stringify(performance.timing)" | jq '.loadEventEnd - .navigationStart'
190
+ playwright-cli --raw eval "JSON.stringify([...document.querySelectorAll('a')].map(a => a.href))" > links.json
191
+ playwright-cli --raw snapshot > before.yml
192
+ playwright-cli click e5
193
+ playwright-cli --raw snapshot > after.yml
194
+ diff before.yml after.yml
195
+ TOKEN=$(playwright-cli --raw cookie-get session_id)
196
+ playwright-cli --raw localstorage-get theme
197
+ ```
198
+
199
+ For structured output wrapping every reply as JSON, pass --json
200
+ ```bash
201
+ playwright-cli list --json
202
+ ```
203
+
204
+ ## Open parameters
205
+ ```bash
206
+ # Use specific browser when creating session
207
+ playwright-cli open --browser=chrome
208
+ playwright-cli open --browser=firefox
209
+ playwright-cli open --browser=webkit
210
+ playwright-cli open --browser=msedge
211
+
212
+ # Use persistent profile (by default profile is in-memory)
213
+ playwright-cli open --persistent
214
+ # Use persistent profile with custom directory
215
+ playwright-cli open --profile=/path/to/profile
216
+
217
+ # Connect to browser via Playwright Extension
218
+ playwright-cli attach --extension=chrome
219
+
220
+ # Connect to a running Chrome or Edge by channel name
221
+ playwright-cli attach --cdp=chrome
222
+ playwright-cli attach --cdp=msedge
223
+
224
+ # Connect to a running browser via CDP endpoint
225
+ playwright-cli attach --cdp=http://localhost:9222
226
+
227
+ # Start with config file
228
+ playwright-cli open --config=my-config.json
229
+
230
+ # Close the browser
231
+ playwright-cli close
232
+ # Detach from an attached browser (leaves the external browser running)
233
+ playwright-cli -s=msedge detach
234
+ # Delete user data for the default session
235
+ playwright-cli delete-data
236
+ ```
237
+
238
+ ## URLs with `&` on Windows
239
+
240
+ On Windows, `cmd.exe` and PowerShell treat `&` as a command separator, so URLs with multiple query parameters get truncated before `playwright-cli` runs. Escape `&` with `^&` in `cmd.exe`, or use `--%` in PowerShell:
241
+
242
+ ```batch
243
+ playwright-cli goto "https://example.com/?a=1^&b=2"
244
+ ```
245
+
246
+ ```powershell
247
+ playwright-cli --% goto "https://example.com/?a=1&b=2"
248
+ ```
249
+
250
+ ## Snapshots
251
+
252
+ After each command, playwright-cli provides a snapshot of the current browser state.
253
+
254
+ ```bash
255
+ > playwright-cli goto https://example.com
256
+ ### Page
257
+ - Page URL: https://example.com/
258
+ - Page Title: Example Domain
259
+ ### Snapshot
260
+ [Snapshot](.playwright-cli/page-2026-02-14T19-22-42-679Z.yml)
261
+ ```
262
+
263
+ You can also take a snapshot on demand using `playwright-cli snapshot` command. All the options below can be combined as needed.
264
+
265
+ ```bash
266
+ # default - save to a file with timestamp-based name
267
+ playwright-cli snapshot
268
+
269
+ # save to file, use when snapshot is a part of the workflow result
270
+ playwright-cli snapshot --filename=after-click.yaml
271
+
272
+ # snapshot an element instead of the whole page
273
+ playwright-cli snapshot "#main"
274
+
275
+ # limit snapshot depth for efficiency, take a partial snapshot afterwards
276
+ playwright-cli snapshot --depth=4
277
+ playwright-cli snapshot e34
278
+
279
+ # include each element's bounding box as [box=x,y,width,height]
280
+ playwright-cli snapshot --boxes
281
+ ```
282
+
283
+ ## Targeting elements
284
+
285
+ By default, use refs from the snapshot to interact with page elements.
286
+
287
+ ```bash
288
+ # get snapshot with refs
289
+ playwright-cli snapshot
290
+
291
+ # interact using a ref
292
+ playwright-cli click e15
293
+ ```
294
+
295
+ You can also use css selectors or Playwright locators.
296
+
297
+ ```bash
298
+ # css selector
299
+ playwright-cli click "#main > button.submit"
300
+
301
+ # role locator
302
+ playwright-cli click "getByRole('button', { name: 'Submit' })"
303
+
304
+ # test id
305
+ playwright-cli click "getByTestId('submit-button')"
306
+ ```
307
+
308
+ ## Browser Sessions
309
+
310
+ ```bash
311
+ # create new browser session named "mysession" with persistent profile
312
+ playwright-cli -s=mysession open example.com --persistent
313
+ # same with manually specified profile directory (use when requested explicitly)
314
+ playwright-cli -s=mysession open example.com --profile=/path/to/profile
315
+ playwright-cli -s=mysession click e6
316
+ playwright-cli -s=mysession close # stop a named browser
317
+ playwright-cli -s=mysession delete-data # delete user data for persistent session
318
+
319
+ playwright-cli list
320
+ # Close all browsers
321
+ playwright-cli close-all
322
+ # Forcefully kill all browser processes
323
+ playwright-cli kill-all
324
+ ```
325
+
326
+ ## Installation
327
+
328
+ If global `playwright-cli` command is not available, try a local version via `npx playwright-cli`:
329
+
330
+ ```bash
331
+ npx --no-install playwright-cli --version
332
+ ```
333
+
334
+ When local version is available, use `npx playwright-cli` in all commands. Otherwise, install `playwright-cli` as a global command:
335
+
336
+ ```bash
337
+ npm install -g @playwright/cli@latest
338
+ ```
339
+
340
+ ## Example: Form submission
341
+
342
+ ```bash
343
+ playwright-cli open https://example.com/form
344
+ playwright-cli snapshot
345
+
346
+ playwright-cli fill e1 "user@example.com"
347
+ playwright-cli fill e2 "password123"
348
+ playwright-cli click e3
349
+ playwright-cli snapshot
350
+ playwright-cli close
351
+ ```
352
+
353
+ ## Example: Multi-tab workflow
354
+
355
+ ```bash
356
+ playwright-cli open https://example.com
357
+ playwright-cli tab-new https://example.com/other
358
+ playwright-cli tab-list
359
+ playwright-cli tab-select 0
360
+ playwright-cli snapshot
361
+ playwright-cli close
362
+ ```
363
+
364
+ ## Example: Debugging with DevTools
365
+
366
+ ```bash
367
+ playwright-cli open https://example.com
368
+ playwright-cli click e4
369
+ playwright-cli fill e7 "test"
370
+ playwright-cli console
371
+ playwright-cli requests
372
+ playwright-cli close
373
+ ```
374
+
375
+ ```bash
376
+ playwright-cli open https://example.com
377
+ playwright-cli tracing-start
378
+ playwright-cli click e4
379
+ playwright-cli fill e7 "test"
380
+ playwright-cli tracing-stop
381
+ playwright-cli close
382
+ ```
383
+
384
+ ## Example: Interactive session
385
+
386
+ 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":
387
+
388
+ ```bash
389
+ playwright-cli open https://example.com
390
+ playwright-cli show --annotate
391
+ ```
392
+
393
+ ## Specific tasks
394
+
395
+ * **Running and Debugging Playwright tests** [references/playwright-tests.md](references/playwright-tests.md)
396
+ * **Request mocking** [references/request-mocking.md](references/request-mocking.md)
397
+ * **Running Playwright code** [references/running-code.md](references/running-code.md)
398
+ * **Browser session management** [references/session-management.md](references/session-management.md)
399
+ * **Spec-driven testing (plan / generate / heal)** [references/spec-driven-testing.md](references/spec-driven-testing.md)
400
+ * **Storage state (cookies, localStorage)** [references/storage-state.md](references/storage-state.md)
401
+ * **Test generation** [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
+ ```