@tea-agent/loop-agent 0.27.1 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/application/task-lifecycle/observe.js +5 -0
- package/dist/application/task-lifecycle/plan-transitions.js +7 -2
- package/dist/cli/program.js +1 -1
- package/dist/commands/client-recovery.js +439 -20
- package/dist/commands/init.js +42 -6
- package/dist/executors/dag-pi-executor.js +143 -38
- package/dist/executors/pi-playwright-cli-tool.js +955 -0
- package/dist/executors/pi-sdk-executor.js +56 -0
- package/dist/executors/playwright-cli-launcher.js +63 -0
- package/dist/executors/shell-executor.js +128 -0
- package/dist/shared/playwright-cli-command-policy.js +41 -0
- package/dist/worker/observability/read-model.js +66 -8
- package/dist/worker/observe/static/dag-model.js +85 -13
- package/dist/workflows/dag/dynamic-runtime/loop-until.js +4 -0
- package/dist/workflows/dag/dynamic-runtime/map.js +13 -13
- package/dist/workflows/dag/frontend-test-case-checklist.js +201 -8
- package/dist/workflows/dag/frontend-test-result-contract.js +52 -3
- package/dist/workflows/dag/init-hybrid.js +116 -30
- package/dist/workflows/dag/lifecycle.js +33 -2
- package/dist/workflows/dag/node-execution.js +11 -5
- package/dist/workflows/dag/output-protocol.js +25 -83
- package/dist/workflows/dag/report.js +9 -2
- package/dist/workflows/dag/rerun-run.js +62 -3
- package/dist/workflows/dag/run-store.js +6 -1
- package/dist/workflows/dag/runner.js +15 -3
- package/dist/workflows/dag/types.js +27 -0
- package/dist/workflows/dag/validate.js +121 -1
- package/docs/architecture/runtime-boundaries.md +13 -11
- package/docs/init-surface.manifest.json +6 -2
- package/docs/templates/README.md +9 -1
- package/docs/templates/frontend-test-dag.generate-cases.prompt.md +14 -7
- package/docs/templates/frontend-test-dag.json +55 -15
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +7 -9
- package/docs/templates/frontend-test-dag.retrospect.prompt.md +1 -1
- package/docs/templates/frontend-test-dag.review-cases.prompt.md +1 -1
- package/docs/templates/frontend-test-dag.review-execution.prompt.md +1 -1
- package/harness.json +1 -1
- package/package.json +1 -1
- package/skills/loop-agent/SKILL.md +1 -1
- package/skills/loop-agent/references/command-reference.md +18 -6
- package/skills/playwright-cli/SKILL.md +69 -402
- package/skills/playwright-cli/references/tracing.md +3 -137
- package/skills/playwright-cli/references/video-recording.md +3 -141
- package/skills/playwright-cli-case-generator/SKILL.md +53 -46
|
@@ -1,420 +1,87 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: playwright-cli
|
|
3
|
-
description:
|
|
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
|
-
##
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
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
|
-
|
|
393
|
-
|
|
394
|
-
|
|
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
|
-
|
|
75
|
+
## 受限证据采集
|
|
404
76
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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
|
-
##
|
|
83
|
+
## 阻塞处理
|
|
411
84
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
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
|
-
|
|
3
|
+
受治理的 `frontend-test` DAG 不提供 tracing 输出能力。
|
|
4
4
|
|
|
5
|
-
|
|
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。需要记录的验证结论应以这些有界证据为准。
|