@tea-agent/loop-agent 0.27.1 → 0.28.1-beta.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/application/task-lifecycle/observe.js +5 -0
  3. package/dist/application/task-lifecycle/plan-transitions.js +7 -2
  4. package/dist/cli/program.js +1 -1
  5. package/dist/commands/client-recovery.js +439 -20
  6. package/dist/commands/init.js +42 -6
  7. package/dist/executors/dag-pi-executor.js +161 -60
  8. package/dist/executors/pi-playwright-cli-tool.js +955 -0
  9. package/dist/executors/pi-sdk-executor.js +56 -0
  10. package/dist/executors/playwright-cli-launcher.js +63 -0
  11. package/dist/executors/shell-executor.js +128 -0
  12. package/dist/shared/playwright-cli-command-policy.js +41 -0
  13. package/dist/task/task-demand-routing.js +1 -15
  14. package/dist/worker/observability/read-model.js +66 -8
  15. package/dist/worker/observe/static/dag-model.js +85 -13
  16. package/dist/workflows/dag/dynamic-runtime/loop-until.js +4 -0
  17. package/dist/workflows/dag/dynamic-runtime/map.js +13 -13
  18. package/dist/workflows/dag/frontend-implementation-contract.js +124 -6
  19. package/dist/workflows/dag/frontend-prewrite-gate.js +22 -8
  20. package/dist/workflows/dag/frontend-test-case-checklist.js +201 -8
  21. package/dist/workflows/dag/frontend-test-result-contract.js +52 -3
  22. package/dist/workflows/dag/init-hybrid.js +181 -68
  23. package/dist/workflows/dag/lifecycle.js +33 -2
  24. package/dist/workflows/dag/node-execution.js +11 -5
  25. package/dist/workflows/dag/output-protocol.js +48 -83
  26. package/dist/workflows/dag/report.js +9 -2
  27. package/dist/workflows/dag/rerun-run.js +62 -3
  28. package/dist/workflows/dag/run-store.js +6 -1
  29. package/dist/workflows/dag/runner.js +15 -3
  30. package/dist/workflows/dag/types.js +27 -0
  31. package/dist/workflows/dag/validate.js +121 -1
  32. package/docs/architecture/runtime-boundaries.md +13 -11
  33. package/docs/init-surface.manifest.json +6 -2
  34. package/docs/templates/README.md +9 -1
  35. package/docs/templates/frontend-implementation-contract.schema.json +2 -2
  36. package/docs/templates/frontend-test-dag.generate-cases.prompt.md +14 -7
  37. package/docs/templates/frontend-test-dag.json +55 -15
  38. package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +7 -9
  39. package/docs/templates/frontend-test-dag.retrospect.prompt.md +1 -1
  40. package/docs/templates/frontend-test-dag.review-cases.prompt.md +1 -1
  41. package/docs/templates/frontend-test-dag.review-execution.prompt.md +1 -1
  42. package/harness.json +1 -1
  43. package/package.json +1 -1
  44. package/skills/loop-agent/SKILL.md +1 -1
  45. package/skills/loop-agent/references/command-reference.md +18 -6
  46. package/skills/playwright-cli/SKILL.md +69 -402
  47. package/skills/playwright-cli/references/tracing.md +3 -137
  48. package/skills/playwright-cli/references/video-recording.md +3 -141
  49. package/skills/playwright-cli-case-generator/SKILL.md +53 -46
@@ -1,420 +1,87 @@
1
1
  ---
2
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:*)
3
+ description: frontend-test DAG 中通过受限的结构化 playwright_cli 工具执行浏览器交互与证据采集。
5
4
  ---
6
5
 
7
6
  # Browser Automation with playwright-cli
8
7
 
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
8
+ ## frontend-test DAG 契约
9
+
10
+ 本 skill 面向 frontend-test DAG browser child。每个浏览器操作都必须转换为一次结构化
11
+ `playwright_cli` tool call:`{ command, args?, timeoutSeconds? }`。
12
+
13
+ - 当前运行时不提供任意命令执行入口;不得尝试其他浏览器自动化工具或测试运行器。
14
+ - 缺少普通终端能力不表示浏览器工具不可用;仅当 preflight 或 `playwright_cli` 明确失败时,记录
15
+ `playwright-cli-unavailable` 或相应 contract error。
16
+ - 不可由受限命令和已记录证据证明的场景必须标记为 `blocked`,不得臆测通过。
17
+ - browser case 只能使用下列 runtime allowlist 中的命令。每个命令行由 controller 转为结构化调用,
18
+ 不直接执行文本命令。
19
+
20
+ ## Runtime allowlist
21
+
22
+ ```text
23
+ open
24
+ close
25
+ goto
26
+ snapshot
27
+ find
28
+ click
29
+ dblclick
30
+ fill
31
+ type
32
+ press
33
+ keydown
34
+ keyup
35
+ hover
36
+ select
37
+ check
38
+ uncheck
39
+ drag
40
+ drop
41
+ upload
42
+ go-back
43
+ go-forward
44
+ reload
45
+ dialog-accept
46
+ dialog-dismiss
47
+ resize
48
+ screenshot
49
+ pdf
50
+ console
51
+ requests
52
+ request
53
+ ```
54
+
55
+ ## 推荐执行流程
56
+
57
+ 使用 controller 冻结的非生产 `baseUrl` 和默认浏览器 session;不得创建 named session。交互前先
58
+ 获取 snapshot,并只使用 snapshot 中可见的 ref 或已知安全 locator。
59
+
60
+ ```text
61
+ playwright-cli open --browser=chrome --headed http://localhost:5173
49
62
  playwright-cli snapshot
50
- # search the snapshot for text or a regexp, returns matching nodes with surrounding context
51
63
  playwright-cli find "Sign in"
52
- playwright-cli find --regex "Sign (in|up)"
53
- # wrap the regexp in slashes to add flags, e.g. /i for case-insensitive
54
- playwright-cli find --regex "/sign (in|up)/i"
55
- playwright-cli eval "document.title"
56
- playwright-cli eval "el => el.textContent" e5
57
- # get element id, class, or any attribute not visible in the snapshot
58
- playwright-cli eval "el => el.id" e5
59
- playwright-cli eval "el => el.getAttribute('data-testid')" e5
60
- playwright-cli dialog-accept
61
- playwright-cli dialog-accept "confirmation text"
62
- playwright-cli dialog-dismiss
63
- playwright-cli resize 1920 1080
64
- playwright-cli close
65
- ```
66
-
67
- ### Navigation
68
-
69
- ```bash
70
- playwright-cli go-back
71
- playwright-cli go-forward
72
- playwright-cli reload
73
- ```
74
-
75
- ### Keyboard
76
-
77
- ```bash
78
- playwright-cli press Enter
79
- playwright-cli press ArrowDown
80
- playwright-cli keydown Shift
81
- playwright-cli keyup Shift
82
- ```
83
-
84
- ### Mouse
85
-
86
- ```bash
87
- playwright-cli mousemove 150 300
88
- playwright-cli mousedown
89
- playwright-cli mousedown right
90
- playwright-cli mouseup
91
- playwright-cli mouseup right
92
- playwright-cli mousewheel 0 100
93
- ```
94
-
95
- ### Save as
96
-
97
- ```bash
98
- playwright-cli screenshot
99
- playwright-cli screenshot e5
100
- playwright-cli screenshot --filename=page.png
101
- playwright-cli screenshot --hires
102
- playwright-cli pdf --filename=page.pdf
103
- ```
104
-
105
- ### Tabs
106
-
107
- ```bash
108
- playwright-cli tab-list
109
- playwright-cli tab-new
110
- playwright-cli tab-new https://example.com/page
111
- playwright-cli tab-close
112
- playwright-cli tab-close 2
113
- playwright-cli tab-select 0
114
- ```
115
-
116
- ### Storage
117
-
118
- ```bash
119
- playwright-cli state-save
120
- playwright-cli state-save auth.json
121
- playwright-cli state-load auth.json
122
-
123
- # Cookies
124
- playwright-cli cookie-list
125
- playwright-cli cookie-list --domain=example.com
126
- playwright-cli cookie-get session_id
127
- playwright-cli cookie-set session_id abc123
128
- playwright-cli cookie-set session_id abc123 --domain=example.com --httpOnly --secure
129
- playwright-cli cookie-delete session_id
130
- playwright-cli cookie-clear
131
-
132
- # LocalStorage
133
- playwright-cli localstorage-list
134
- playwright-cli localstorage-get theme
135
- playwright-cli localstorage-set theme dark
136
- playwright-cli localstorage-delete theme
137
- playwright-cli localstorage-clear
138
-
139
- # SessionStorage
140
- playwright-cli sessionstorage-list
141
- playwright-cli sessionstorage-get step
142
- playwright-cli sessionstorage-set step 3
143
- playwright-cli sessionstorage-delete step
144
- playwright-cli sessionstorage-clear
145
- ```
146
-
147
- ### Network
148
-
149
- ```bash
150
- playwright-cli route "**/*.jpg" --status=404
151
- playwright-cli route "https://api.example.com/**" --body='{"mock": true}'
152
- playwright-cli route-list
153
- playwright-cli unroute "**/*.jpg"
154
- playwright-cli unroute
155
- ```
156
-
157
- ### DevTools
158
-
159
- ```bash
160
- playwright-cli console
161
- playwright-cli console warning
162
- playwright-cli requests
163
- playwright-cli request 5
164
- playwright-cli run-code "async page => await page.context().grantPermissions(['geolocation'])"
165
- playwright-cli run-code --filename=script.js
166
- playwright-cli tracing-start
167
- playwright-cli tracing-stop
168
- playwright-cli video-start video.webm
169
- playwright-cli video-chapter "Chapter Title" --description="Details" --duration=2000
170
- playwright-cli video-stop
171
-
172
- # annotate each subsequent action (click, type, ...) with a callout naming the action and highlighting the target
173
- playwright-cli video-show-actions --duration=600 --position=top-right
174
- playwright-cli video-hide-actions
175
-
176
- # launch the dashboard for UI review / design feedback — user annotates the page, you receive the annotated screenshot, snapshot, and notes
177
- playwright-cli show --annotate
178
-
179
- # generate a Playwright locator for an element from its ref or selector
180
- playwright-cli generate-locator e5 --raw
181
-
182
- # show a persistent highlight overlay for an element, optionally with a custom style
183
- playwright-cli highlight e5
184
- playwright-cli highlight e5 --style="outline: 3px dashed red"
185
- # hide a single element highlight, or all page highlights when no target is given
186
- playwright-cli highlight e5 --hide
187
- playwright-cli highlight --hide
188
- ```
189
-
190
- ## Raw output
191
-
192
- 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.
193
-
194
- ```bash
195
- playwright-cli --raw eval "JSON.stringify(performance.timing)" | jq '.loadEventEnd - .navigationStart'
196
- playwright-cli --raw eval "JSON.stringify([...document.querySelectorAll('a')].map(a => a.href))" > links.json
197
- playwright-cli --raw snapshot > before.yml
198
- playwright-cli click e5
199
- playwright-cli --raw snapshot > after.yml
200
- diff before.yml after.yml
201
- TOKEN=$(playwright-cli --raw cookie-get session_id)
202
- playwright-cli --raw localstorage-get theme
203
- ```
204
-
205
- For structured output wrapping every reply as JSON, pass --json
206
- ```bash
207
- playwright-cli list --json
208
- ```
209
-
210
- ## Open parameters
211
- ```bash
212
- # Use specific browser when creating session
213
- playwright-cli open --browser=chrome
214
- playwright-cli open --browser=firefox
215
- playwright-cli open --browser=webkit
216
- playwright-cli open --browser=msedge
217
-
218
- # Emulate a generic mobile device (Pixel 10 for Chromium, iPhone 17 for WebKit).
219
- # Prefer this when a mobile layout is acceptable: mobile pages are usually
220
- # lighter, so snapshots are smaller and cheaper.
221
- playwright-cli open --mobile
222
- playwright-cli open --device="iPhone 15"
223
-
224
- # Use persistent profile (by default profile is in-memory)
225
- playwright-cli open --persistent
226
- # Use persistent profile with custom directory
227
- playwright-cli open --profile=/path/to/profile
228
-
229
- # Connect to browser via Playwright Extension
230
- playwright-cli attach --extension=chrome
231
-
232
- # Connect to a running Chrome or Edge by channel name
233
- playwright-cli attach --cdp=chrome
234
- playwright-cli attach --cdp=msedge
235
-
236
- # Connect to a running browser via CDP endpoint
237
- playwright-cli attach --cdp=http://localhost:9222
238
-
239
- # Start with config file
240
- playwright-cli open --config=my-config.json
241
-
242
- # Close the browser
243
- playwright-cli close
244
- # Detach from an attached browser (leaves the external browser running)
245
- playwright-cli -s=msedge detach
246
- # Delete user data for the default session
247
- playwright-cli delete-data
248
- ```
249
-
250
- ## URLs with `&` on Windows
251
-
252
- 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:
253
-
254
- ```batch
255
- playwright-cli goto "https://example.com/?a=1^&b=2"
256
- ```
257
-
258
- ```powershell
259
- playwright-cli --% goto "https://example.com/?a=1&b=2"
260
- ```
261
-
262
- ## Snapshots
263
-
264
- After each command, playwright-cli provides a snapshot of the current browser state.
265
-
266
- ```bash
267
- > playwright-cli goto https://example.com
268
- ### Page
269
- - Page URL: https://example.com/
270
- - Page Title: Example Domain
271
- ### Snapshot
272
- [Snapshot](.playwright-cli/page-2026-02-14T19-22-42-679Z.yml)
273
- ```
274
-
275
- You can also take a snapshot on demand using `playwright-cli snapshot` command. All the options below can be combined as needed.
276
-
277
- ```bash
278
- # default - save to a file with timestamp-based name
279
- playwright-cli snapshot
280
-
281
- # save to file, use when snapshot is a part of the workflow result
282
- playwright-cli snapshot --filename=after-click.yaml
283
-
284
- # snapshot an element instead of the whole page
285
- playwright-cli snapshot "#main"
286
-
287
- # limit snapshot depth for efficiency, take a partial snapshot afterwards
288
- playwright-cli snapshot --depth=4
289
- playwright-cli snapshot e34
290
-
291
- # include each element's bounding box as [box=x,y,width,height]
292
- playwright-cli snapshot --boxes
293
-
294
- # search a large snapshot instead of capturing it all — returns matching nodes
295
- # with 3 lines of context around each match (like grep -C)
296
- playwright-cli find "Add to cart"
297
- playwright-cli find --regex "\\$[0-9]+\\.[0-9]{2}"
298
- ```
299
-
300
- ## Targeting elements
301
-
302
- By default, use refs from the snapshot to interact with page elements.
303
-
304
- ```bash
305
- # get snapshot with refs
306
- playwright-cli snapshot
307
-
308
- # interact using a ref
309
- playwright-cli click e15
310
- ```
311
-
312
- You can also use css selectors or Playwright locators.
313
-
314
- ```bash
315
- # css selector
316
- playwright-cli click "#main > button.submit"
317
-
318
- # role locator
319
- playwright-cli click "getByRole('button', { name: 'Submit' })"
320
-
321
- # test id
322
- playwright-cli click "getByTestId('submit-button')"
323
- ```
324
-
325
- ## Browser Sessions
326
-
327
- ```bash
328
- # create new browser session named "mysession" with persistent profile
329
- playwright-cli -s=mysession open example.com --persistent
330
- # same with manually specified profile directory (use when requested explicitly)
331
- playwright-cli -s=mysession open example.com --profile=/path/to/profile
332
- playwright-cli -s=mysession click e6
333
- playwright-cli -s=mysession close # stop a named browser
334
- playwright-cli -s=mysession delete-data # delete user data for persistent session
335
-
336
- playwright-cli list
337
- # Close all browsers
338
- playwright-cli close-all
339
- # Forcefully kill all browser processes
340
- playwright-cli kill-all
341
- ```
342
-
343
- ## Installation
344
-
345
- If global `playwright-cli` command is not available, try a local version via `npx playwright cli`:
346
-
347
- ```bash
348
- npx --no-install playwright --version
349
- ```
350
-
351
- When local version is available, use `npx playwright cli` in all commands. Otherwise, install `playwright-cli` as a global command:
352
-
353
- ```bash
354
- npm install -g @playwright/cli@latest
355
- ```
356
-
357
- ## Example: Form submission
358
-
359
- ```bash
360
- playwright-cli open https://example.com/form
361
- playwright-cli snapshot
362
-
363
64
  playwright-cli fill e1 "user@example.com"
364
65
  playwright-cli fill e2 "password123"
365
66
  playwright-cli click e3
366
- playwright-cli snapshot
367
- playwright-cli close
368
- ```
369
-
370
- ## Example: Multi-tab workflow
371
-
372
- ```bash
373
- playwright-cli open https://example.com
374
- playwright-cli tab-new https://example.com/other
375
- playwright-cli tab-list
376
- playwright-cli tab-select 0
377
- playwright-cli snapshot
378
- playwright-cli close
379
- ```
380
-
381
- ## Example: Debugging with DevTools
382
-
383
- ```bash
384
- playwright-cli open https://example.com
385
- playwright-cli click e4
386
- playwright-cli fill e7 "test"
387
- playwright-cli console
388
- playwright-cli requests
67
+ playwright-cli find "Welcome"
389
68
  playwright-cli close
390
69
  ```
391
70
 
392
- ```bash
393
- playwright-cli open https://example.com
394
- playwright-cli tracing-start
395
- playwright-cli click e4
396
- playwright-cli fill e7 "test"
397
- playwright-cli tracing-stop
398
- playwright-cli close
399
- ```
400
-
401
- ## Example: Interactive session
71
+ 成功的 `find` 是唯一可用于 UI 语义断言的浏览器证据。`snapshot`、导航、截图、网络观察、
72
+ 普通交互和控制台输出均不能单独取得 passed authority。通过的 case 还需要同一 child 的有序
73
+ controller receipts:successful `open` → successful `find` → successful post-execution cleanup。
402
74
 
403
- 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":
75
+ ## 受限证据采集
404
76
 
405
- ```bash
406
- playwright-cli open https://example.com
407
- playwright-cli show --annotate
408
- ```
77
+ - UI 状态:先 `snapshot`,完成交互后以成功 `find` 证明用户可见结果。
78
+ - 后端观察:可使用 `requests` 列出已观察到的请求,再以 `request <id>` 查看单个已观察请求。
79
+ 这类观察不能替代成功 `find` 的 UI 语义证据。
80
+ - 文件型证据:`screenshot` 与 `pdf` 必须使用 `--filename <file>`,且文件名由 controller 规范化到当前 case evidence 目录。截图一律写为 `playwright-cli screenshot --filename final.png`;有真实元素 ref 时写为 `playwright-cli screenshot e5 --filename final.png`。`pdf` 写为 `playwright-cli pdf --filename final.pdf`。`snapshot` 不带 filename 时只返回响应;需要文件时写为 `playwright-cli snapshot --filename snapshot.txt`。不得使用 `--path`、`--output`、`--file`,也不得把文件路径作为位置参数。
81
+ - 对话框、上传、拖放和视口变化仅在 case 已给出所需前置条件时使用对应 allowlist 命令。
409
82
 
410
- ## Specific tasks
83
+ ## 阻塞处理
411
84
 
412
- * **Running and Debugging Playwright tests** [references/playwright-tests.md](references/playwright-tests.md)
413
- * **Request mocking** [references/request-mocking.md](references/request-mocking.md)
414
- * **Running Playwright code** [references/running-code.md](references/running-code.md)
415
- * **Browser session management** [references/session-management.md](references/session-management.md)
416
- * **Storage state (cookies, localStorage)** [references/storage-state.md](references/storage-state.md)
417
- * **Test generation (plan / generate / heal)** [references/test-generation.md](references/test-generation.md)
418
- * **Tracing** [references/tracing.md](references/tracing.md)
419
- * **Video recording** [references/video-recording.md](references/video-recording.md)
420
- * **Inspecting element attributes** [references/element-attributes.md](references/element-attributes.md)
85
+ 当环境、数据、权限、时序、异常路径或响应内容无法用 RAG、冻结配置和 runtime allowlist 证明时,
86
+ 写入 `blocked` evidence,并提供具体 `blockedReason`。不要引入替代执行路径,也不要把隐藏状态或
87
+ 未观察到的网络结果当作通过证据。
@@ -1,139 +1,5 @@
1
- # Tracing
1
+ # Tracing 输出边界
2
2
 
3
- Capture detailed execution traces for debugging and analysis. Traces include DOM snapshots, screenshots, network activity, and console logs.
3
+ 受治理的 `frontend-test` DAG 不提供 tracing 输出能力。
4
4
 
5
- ## Basic Usage
6
-
7
- ```bash
8
- # Start trace recording
9
- playwright-cli tracing-start
10
-
11
- # Perform actions
12
- playwright-cli open https://example.com
13
- playwright-cli click e1
14
- playwright-cli fill e2 "test"
15
-
16
- # Stop trace recording
17
- playwright-cli tracing-stop
18
- ```
19
-
20
- ## Trace Output Files
21
-
22
- When you start tracing, Playwright creates a `traces/` directory with several files:
23
-
24
- ### `trace-{timestamp}.trace`
25
-
26
- **Action log** - The main trace file containing:
27
- - Every action performed (clicks, fills, navigations)
28
- - DOM snapshots before and after each action
29
- - Screenshots at each step
30
- - Timing information
31
- - Console messages
32
- - Source locations
33
-
34
- ### `trace-{timestamp}.network`
35
-
36
- **Network log** - Complete network activity:
37
- - All HTTP requests and responses
38
- - Request headers and bodies
39
- - Response headers and bodies
40
- - Timing (DNS, connect, TLS, TTFB, download)
41
- - Resource sizes
42
- - Failed requests and errors
43
-
44
- ### `resources/`
45
-
46
- **Resources directory** - Cached resources:
47
- - Images, fonts, stylesheets, scripts
48
- - Response bodies for replay
49
- - Assets needed to reconstruct page state
50
-
51
- ## What Traces Capture
52
-
53
- | Category | Details |
54
- |----------|---------|
55
- | **Actions** | Clicks, fills, hovers, keyboard input, navigations |
56
- | **DOM** | Full DOM snapshot before/after each action |
57
- | **Screenshots** | Visual state at each step |
58
- | **Network** | All requests, responses, headers, bodies, timing |
59
- | **Console** | All console.log, warn, error messages |
60
- | **Timing** | Precise timing for each operation |
61
-
62
- ## Use Cases
63
-
64
- ### Debugging Failed Actions
65
-
66
- ```bash
67
- playwright-cli tracing-start
68
- playwright-cli open https://app.example.com
69
-
70
- # This click fails - why?
71
- playwright-cli click e5
72
-
73
- playwright-cli tracing-stop
74
- # Open trace to see DOM state when click was attempted
75
- ```
76
-
77
- ### Analyzing Performance
78
-
79
- ```bash
80
- playwright-cli tracing-start
81
- playwright-cli open https://slow-site.com
82
- playwright-cli tracing-stop
83
-
84
- # View network waterfall to identify slow resources
85
- ```
86
-
87
- ### Capturing Evidence
88
-
89
- ```bash
90
- # Record a complete user flow for documentation
91
- playwright-cli tracing-start
92
-
93
- playwright-cli open https://app.example.com/checkout
94
- playwright-cli fill e1 "4111111111111111"
95
- playwright-cli fill e2 "12/25"
96
- playwright-cli fill e3 "123"
97
- playwright-cli click e4
98
-
99
- playwright-cli tracing-stop
100
- # Trace shows exact sequence of events
101
- ```
102
-
103
- ## Trace vs Video vs Screenshot
104
-
105
- | Feature | Trace | Video | Screenshot |
106
- |---------|-------|-------|------------|
107
- | **Format** | .trace file | .webm video | .png/.jpeg image |
108
- | **DOM inspection** | Yes | No | No |
109
- | **Network details** | Yes | No | No |
110
- | **Step-by-step replay** | Yes | Continuous | Single frame |
111
- | **File size** | Medium | Large | Small |
112
- | **Best for** | Debugging | Demos | Quick capture |
113
-
114
- ## Best Practices
115
-
116
- ### 1. Start Tracing Before the Problem
117
-
118
- ```bash
119
- # Trace the entire flow, not just the failing step
120
- playwright-cli tracing-start
121
- playwright-cli open https://example.com
122
- # ... all steps leading to the issue ...
123
- playwright-cli tracing-stop
124
- ```
125
-
126
- ### 2. Clean Up Old Traces
127
-
128
- Traces can consume significant disk space:
129
-
130
- ```bash
131
- # Remove traces older than 7 days
132
- find .playwright-cli/traces -mtime +7 -delete
133
- ```
134
-
135
- ## Limitations
136
-
137
- - Traces add overhead to automation
138
- - Large traces can consume significant disk space
139
- - Some dynamic content may not replay perfectly
5
+ DAG 的证据边界仅保留有界的 screenshot、pdf 和 snapshot evidence。需要记录的验证结论应以这些有界证据为准。