@playcraft/cli 0.0.57 → 0.0.59
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/README.md +34 -16
- package/dist/cli-root-help.js +1 -0
- package/dist/commands/build-all.js +10 -9
- package/dist/commands/build.js +13 -12
- package/dist/commands/create.js +26 -33
- package/dist/commands/platform-skills.generated.js +19 -0
- package/dist/commands/skills.js +2 -0
- package/dist/commands/tools-generation.js +1 -1
- package/dist/commands/workspace-runtime.js +54 -0
- package/dist/index.js +3 -1
- package/dist/project-skills/commands.js +72 -0
- package/dist/project-skills/lifecycle.js +28 -0
- package/dist/project-skills/local-run.js +112 -0
- package/dist/project-skills/local-store.js +149 -0
- package/dist/project-skills/messages.js +72 -0
- package/dist/project-skills/reconcile.js +62 -0
- package/dist/project-skills/remote-cache.js +51 -0
- package/dist/project-skills/validation.js +19 -0
- package/dist/remix/clone.js +2 -0
- package/dist/remix/init-template.js +2 -0
- package/dist/remix/pull.js +2 -0
- package/dist/remix/push.js +21 -1
- package/dist/utils/agent-api-client.js +54 -17
- package/dist/utils/tool-operation-journal.js +54 -0
- package/dist/workspace-runtime/codex/app-server.js +395 -0
- package/dist/workspace-runtime/codex/config-toml.js +25 -0
- package/dist/workspace-runtime/codex/jsonrpc-stdio.js +106 -0
- package/dist/workspace-runtime/codex/loopback.js +59 -0
- package/dist/workspace-runtime/codex/native-adapter.js +3 -0
- package/dist/workspace-runtime/main.js +10 -0
- package/dist/workspace-runtime/persistence/journal.js +350 -0
- package/dist/workspace-runtime/processes/managed-writes.js +69 -0
- package/dist/workspace-runtime/serve.js +111 -0
- package/dist/workspace-runtime/server/auth.js +21 -0
- package/dist/workspace-runtime/server/dispatch.js +861 -0
- package/dist/workspace-runtime/server/execution-group.js +88 -0
- package/dist/workspace-runtime/server/http.js +561 -0
- package/dist/workspace-runtime/server/lock.js +53 -0
- package/dist/workspace-runtime/server/types.js +1 -0
- package/dist/workspace-runtime/workspaces/context-error.js +2 -0
- package/dist/workspace-runtime/workspaces/file-snapshot.js +213 -0
- package/dist/workspace-runtime/workspaces/files.js +143 -0
- package/dist/workspace-runtime/workspaces/git.js +242 -0
- package/dist/workspace-runtime/workspaces/json5-edit.js +170 -0
- package/dist/workspace-runtime/workspaces/parameters.js +272 -0
- package/dist/workspace-runtime/workspaces/prepare.js +364 -0
- package/dist/workspace-runtime/workspaces/registry.js +107 -0
- package/dist/workspace-runtime/workspaces/revisions.js +31 -0
- package/package.json +6 -3
- package/project-template-v2/.claude/agents/artist.md +82 -0
- package/project-template-v2/.claude/agents/developer.md +153 -0
- package/project-template-v2/.claude/agents/game-designer.md +264 -0
- package/project-template-v2/.claude/agents/refs/artist-art-style-catalog.md +533 -0
- package/project-template-v2/.claude/agents/refs/artist-color-audio-recipes.md +153 -0
- package/project-template-v2/.claude/agents/refs/artist-dimension-axis.md +27 -0
- package/project-template-v2/.claude/agents/refs/artist-master-composite-recipes.md +208 -0
- package/project-template-v2/.claude/agents/refs/atom-skill-library.md +81 -0
- package/project-template-v2/.claude/agents/refs/developer-impl-cookbook.md +432 -0
- package/project-template-v2/.claude/agents/refs/framework-5-component-filter.md +252 -0
- package/project-template-v2/.claude/agents/refs/framework-game-feel-juice.md +266 -0
- package/project-template-v2/.claude/agents/refs/framework-mda.md +147 -0
- package/project-template-v2/.claude/agents/refs/game-designer-gameplay-sufficiency.md +123 -0
- package/project-template-v2/.claude/agents/refs/ta-3d-flip-recipe.md +88 -0
- package/project-template-v2/.claude/agents/refs/ta-atlas-deliverable-standard.md +67 -0
- package/project-template-v2/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
- package/project-template-v2/.claude/agents/refs/ta-image-generation-detail.md +300 -0
- package/project-template-v2/.claude/agents/refs/ta-image-ops-reference.md +495 -0
- package/project-template-v2/.claude/agents/refs/ta-pipeline-cookbook.md +1141 -0
- package/project-template-v2/.claude/agents/refs/ta-tools-reference.md +111 -0
- package/project-template-v2/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
- package/project-template-v2/.claude/agents/refs/threejs-cannon-pitfalls.md +412 -0
- package/project-template-v2/.claude/agents/reviewer.md +75 -0
- package/project-template-v2/.claude/agents/technical-artist.md +86 -0
- package/project-template-v2/.claude/hooks/snapshot-milestone.mjs +243 -0
- package/project-template-v2/.claude/hooks/user-prompt.mjs +133 -0
- package/project-template-v2/.claude/settings.json +33 -0
- package/project-template-v2/.claude/skills/brainstorming/SKILL.md +161 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/frame-template.html +270 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/helper.js +177 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/server.cjs +354 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/start-server.sh +148 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/stop-server.sh +56 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/wait-for-selection.sh +62 -0
- package/project-template-v2/.claude/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/project-template-v2/.claude/skills/brainstorming/visual-companion.md +309 -0
- package/project-template-v2/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
- package/project-template-v2/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
- package/project-template-v2/.claude/skills/playcraft-asset-state-sheet/SKILL.md +205 -0
- package/project-template-v2/.claude/skills/playcraft-audio-generation/SKILL.md +280 -0
- package/project-template-v2/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
- package/project-template-v2/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/SKILL.md +298 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +324 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +97 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +137 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
- package/project-template-v2/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
- package/project-template-v2/.claude/skills/playcraft-image-processing/SKILL.md +219 -0
- package/project-template-v2/.claude/skills/playcraft-masking/SKILL.md +373 -0
- package/project-template-v2/.claude/skills/playcraft-playable-optimization/SKILL.md +161 -0
- package/project-template-v2/.claude/skills/playcraft-research/SKILL.md +215 -0
- package/project-template-v2/.claude/skills/playcraft-skill-recommender/SKILL.md +382 -0
- package/project-template-v2/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
- package/project-template-v2/.claude/skills/playcraft-sprite-remix/SKILL.md +158 -0
- package/project-template-v2/.claude/skills/playcraft-sprite-sheet/SKILL.md +100 -0
- package/project-template-v2/.claude/skills/playcraft-storyboard/SKILL.md +167 -0
- package/project-template-v2/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
- package/project-template-v2/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
- package/project-template-v2/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
- package/project-template-v2/.claude/skills/playwright-cli/SKILL.md +390 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/running-code.md +240 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/session-management.md +226 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/spec-driven-testing.md +308 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/storage-state.md +275 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/test-generation.md +134 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/tracing.md +142 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/video-recording.md +153 -0
- package/project-template-v2/.claude/skills/session-analyzer/SKILL.md +386 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/execution-breakdown.mjs +182 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/find-turns.mjs +72 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/heavy-output.mjs +121 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/resolve-session.mjs +102 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-stats.mjs +127 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-tool-timeline.mjs +106 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/time-gaps.mjs +128 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/turn-timeline.mjs +67 -0
- package/project-template-v2/.claude/snapshot.mjs +263 -0
- package/project-template-v2/.playcraft/skills.lock.json +152 -0
- package/project-template-v2/CLAUDE.md +146 -0
- package/project-template-v2/assets/audio/bgm/.gitkeep +0 -0
- package/project-template-v2/assets/audio/sfx/.gitkeep +0 -0
- package/project-template-v2/assets/bundles/.gitkeep +0 -0
- package/project-template-v2/assets/images/bg/.gitkeep +0 -0
- package/project-template-v2/assets/images/reference/.gitkeep +0 -0
- package/project-template-v2/assets/images/storyboard/.gitkeep +0 -0
- package/project-template-v2/assets/images/tiles/.gitkeep +0 -0
- package/project-template-v2/assets/images/ui/.gitkeep +0 -0
- package/project-template-v2/assets/images/vfx/.gitkeep +0 -0
- package/project-template-v2/assets/models/.gitkeep +0 -0
- package/project-template-v2/docs/harness/iteration-1/context-flow.md +254 -0
- package/project-template-v2/docs/harness/iteration-1/generate-flow.md +91 -0
- package/project-template-v2/docs/harness/iteration-1/ideate-flow.md +214 -0
- package/project-template-v2/docs/harness/iteration-1/optimize-flow.md +75 -0
- package/project-template-v2/docs/harness/iteration-1/wrapup-flow.md +63 -0
- package/project-template-v2/docs/harness/iteration-2/context-flow.md +223 -0
- package/project-template-v2/docs/harness/iteration-2/generate-flow.md +129 -0
- package/project-template-v2/docs/harness/iteration-2/ideate-flow.md +267 -0
- package/project-template-v2/docs/harness/iteration-2/optimize-flow.md +164 -0
- package/project-template-v2/docs/harness/iteration-2/wrapup-flow.md +115 -0
- package/project-template-v2/docs/harness/orchestrator-flow.md +364 -0
- package/project-template-v2/docs/project-state.json +60 -0
- package/project-template-v2/docs/project-state.md +72 -0
- package/project-template-v2/docs/standards/README.md +225 -0
- package/project-template-v2/docs/standards/agent-behavior-standards.md +174 -0
- package/project-template-v2/docs/standards/artifacts/design-brief.md +19 -0
- package/project-template-v2/docs/standards/artifacts/design.md +22 -0
- package/project-template-v2/docs/standards/artifacts/game-code.md +41 -0
- package/project-template-v2/docs/standards/artifacts/todo-list.md +41 -0
- package/project-template-v2/docs/standards/iter1-agent-behavior-standards.md +343 -0
- package/project-template-v2/game/index.ts +18 -0
- package/project-template-v2/globals.d.ts +51 -0
- package/project-template-v2/index.css +34 -0
- package/project-template-v2/index.html +18 -0
- package/project-template-v2/main.ts +9 -0
- package/project-template-v2/package.json +46 -0
- package/project-template-v2/skills/_shared/scripts/dispatch-clear.mjs +31 -0
- package/project-template-v2/skills/_shared/scripts/dispatch-set.mjs +86 -0
- package/project-template-v2/skills/_shared/scripts/dod-check.mjs +153 -0
- package/project-template-v2/skills/_shared/scripts/handoff-append.mjs +70 -0
- package/project-template-v2/skills/_shared/scripts/lib/validator-artifacts.mjs +91 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/dod-config.mjs +131 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/index.mjs +80 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/iteration-1-core.mjs +90 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/iteration-2-wrap.mjs +93 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/iteration-3-visual.mjs +23 -0
- package/project-template-v2/skills/_shared/scripts/render-project-state.mjs +230 -0
- package/project-template-v2/skills/_shared/scripts/state-advance-stage.mjs +58 -0
- package/project-template-v2/skills/_shared/scripts/state-get.mjs +339 -0
- package/project-template-v2/skills/_shared/scripts/state-handoff.mjs +39 -0
- package/project-template-v2/skills/_shared/scripts/state-set.mjs +94 -0
- package/project-template-v2/skills/_shared/scripts/state-store.mjs +783 -0
- package/project-template-v2/skills/_shared/scripts/todo-add.mjs +88 -0
- package/project-template-v2/skills/_shared/scripts/todo-get.mjs +130 -0
- package/project-template-v2/skills/_shared/scripts/todo-remove.mjs +33 -0
- package/project-template-v2/skills/_shared/scripts/todo-set.mjs +47 -0
- package/project-template-v2/skills/_shared/scripts/verify-asset-code-sync.mjs +268 -0
- package/project-template-v2/skills/_shared/scripts/verify-env.mjs +285 -0
- package/project-template-v2/skills/_shared/scripts/verify-placeholders.mjs +161 -0
- package/project-template-v2/skills/playable-autoplay/SKILL.md +176 -0
- package/project-template-v2/skills/playable-autoplay/agents/openai.yaml +4 -0
- package/project-template-v2/skills/playable-debug/SKILL.md +116 -0
- package/project-template-v2/skills/playable-debug/agents/openai.yaml +4 -0
- package/project-template-v2/skills/playable-debug/references/debug-config.md +40 -0
- package/project-template-v2/skills/playable-record/SKILL.md +140 -0
- package/project-template-v2/skills/playable-record/scripts/lib/dev-server.mjs +104 -0
- package/project-template-v2/skills/playable-record/scripts/lib/record-audio-bridge.js +141 -0
- package/project-template-v2/skills/playable-record/scripts/record-playable.mjs +425 -0
- package/project-template-v2/skills/playable-record/scripts/verify-contract.mjs +261 -0
- package/project-template-v2/skills/playable-record/scripts/verify-firstwin.mjs +398 -0
- package/project-template-v2/skills/playable-record/scripts/verify-fusion.mjs +322 -0
- package/project-template-v2/skills/playable-record/scripts/verify-lifecycle.mjs +105 -0
- package/project-template-v2/skills/playable-record/scripts/verify-vlm-video.mjs +230 -0
- package/project-template-v2/skills/playable-validate/SKILL.md +61 -0
- package/project-template-v2/skills/playable-validate/validation-rules.md +14 -0
- package/project-template-v2/skills/playable-verify-ui/SKILL.md +63 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/__init__.py +1 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/config_expr.js +218 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/node_utils.js +51 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/profile_loader.py +59 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/report.py +106 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/runtime_contract.js +116 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_fetch_antipatterns.py +59 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_hardcoded_layout.js +64 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_runtime_contract.js +58 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_text_overlap.py +333 -0
- package/project-template-v2/ta-workspace/scripts/.gitkeep +0 -0
- package/project-template-v2/tsconfig.json +20 -0
- package/project-template-v2/vite.config.ts +27 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playcraft-vfx-animation
|
|
3
|
+
description: VFX 特效与动画精灵图选型决策树与核心命令速查。按游戏事件快速选定预设,详细预设目录见 refs/ta-vfx-preset-catalog.md。
|
|
4
|
+
triggers: VFX,特效,动画,animate,animation,use-vfx,精灵动画,sprite animation,爆炸特效,闪光效果,vfx预设,animate预设,bounce,spin,pulse,shake,float,blink,swing,wobble,flip,confetti,sparkle,explosion,starburst,smoke,glow,impact
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PlayCraft VFX 特效与动画精灵图生成指南
|
|
8
|
+
|
|
9
|
+
## 0. Overview
|
|
10
|
+
|
|
11
|
+
VFX(视觉特效精灵图)和 animate(运动动画精灵图)是可玩广告视觉品质的关键层。它们属于 TA 工作流的 **Stage B**(精灵图处理阶段),在 Stage A 元素生成完成后执行。
|
|
12
|
+
|
|
13
|
+
- **VFX**:预制粒子/爆炸/光效精灵表,用于游戏事件反馈(消除、得分、胜利等)
|
|
14
|
+
- **animate**:将静态素材转为循环动画精灵表,用于 idle 状态、UI 引导、装饰运动
|
|
15
|
+
|
|
16
|
+
**发现可用预设**:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
playcraft image list-vfx # 列出所有 VFX 预设(含帧数、体积)
|
|
20
|
+
playcraft image animate --list-presets # 列出所有 animate 预设
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 1. VFX 选型决策树
|
|
24
|
+
|
|
25
|
+
按游戏事件选择预设:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
需要为哪种游戏事件添加 VFX?
|
|
29
|
+
+-- 元素消除/击破 -> explosion_small (8帧, ~30KB)
|
|
30
|
+
| 理由: 中心爆发+碎片扩散, 8帧在视觉冲击与体积间取得平衡
|
|
31
|
+
+-- 得分/收集奖励 -> sparkle (6帧, ~15KB)
|
|
32
|
+
| 理由: 轻量粒子迸发, 15KB 可高频触发而不累积体积压力
|
|
33
|
+
+-- 关卡完成/大胜利 -> confetti (12帧, ~25KB)
|
|
34
|
+
| 理由: 多彩纸片飘落, 12帧保证庆祝感的持续时长
|
|
35
|
+
+-- 连击触发/特殊技能 -> starburst (8帧, ~20KB)
|
|
36
|
+
| 理由: 金色放射线条, 视觉冲击强且不遮挡游戏元素
|
|
37
|
+
+-- 元素消失/冲刺残影 -> smoke (8帧, ~20KB)
|
|
38
|
+
| 理由: 烟雾自然消散, 柔和过渡不抢视觉焦点
|
|
39
|
+
+-- 元素高亮/选中状态 -> glow (6帧, ~10KB)
|
|
40
|
+
| 理由: 最小体积, 适合持续循环播放(选中状态)
|
|
41
|
+
+-- 落地/点击反馈 -> impact_ring (6帧, ~15KB)
|
|
42
|
+
| 理由: 快速扩散环, 6帧短促匹配瞬时反馈的时间尺度
|
|
43
|
+
+-- 金币/货币拾取 -> coin_collect (8帧, ~20KB)
|
|
44
|
+
理由: 专用金色闪光发散, 与通用 sparkle 区分货币语义
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 2. Animate 选型决策树
|
|
48
|
+
|
|
49
|
+
按运动需求选择预设:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
需要什么运动效果?
|
|
53
|
+
+-- 引起注意(CTA/重要按钮) -> pulse (缩放脉冲, 周期1.5-2s)
|
|
54
|
+
| 理由: 缩放振荡是最有效的注意力引导, 不依赖位移空间
|
|
55
|
+
+-- 持续旋转(加载/转盘/金币) -> spin (X轴缩放模拟Y轴旋转)
|
|
56
|
+
| 理由: 2D压缩模拟3D翻转, 适合圆形/对称元素
|
|
57
|
+
+-- 弹跳反馈(点击/收集/idle) -> bounce (Y轴正弦平移)
|
|
58
|
+
| 理由: 最自然的"活着"感, 适用面最广
|
|
59
|
+
+-- 错误/警告/受击 -> shake (随机小幅XY偏移)
|
|
60
|
+
| 理由: 随机位移制造紧张感, 强制引导注意力
|
|
61
|
+
+-- 悬浮装饰(idle/魔法道具) -> float (轻柔漂浮+微旋转)
|
|
62
|
+
| 理由: 比bounce更轻柔, 加入+-3度旋转增添神秘感
|
|
63
|
+
+-- 闪烁提示(光标/倒计时) -> blink (不透明度振荡)
|
|
64
|
+
| 理由: 最简单的"请注意我"动画, 最小视觉干扰
|
|
65
|
+
+-- 钟摆装饰(悬挂物/灯笼) -> swing (绕顶部中心摆动)
|
|
66
|
+
| 理由: 物理感强, 专为"挂着"的元素设计
|
|
67
|
+
+-- 可爱/卡通idle(果冻/气泡) -> wobble (左右交替小幅旋转)
|
|
68
|
+
| 理由: +-5-10度交替旋转产生弹性感, 适合软体元素
|
|
69
|
+
+-- 卡牌翻转/3D旋转 -> flip (需要正面+背面两张素材)
|
|
70
|
+
理由: 完整正面->过渡->背面翻转; 详见 ta-3d-flip-recipe.md
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 3. Core Commands
|
|
74
|
+
|
|
75
|
+
### use-vfx 完整示例
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
playcraft image use-vfx \
|
|
79
|
+
--preset explosion_small \ # 预设名(必填), 从决策树选定
|
|
80
|
+
--tint "#FF6B35" \ # 颜色叠加(可选), hex格式, 按元素颜色调整
|
|
81
|
+
--scale 1.2 \ # 缩放(可选, 默认1.0), 范围0.5-3.0
|
|
82
|
+
--output assets/images/vfx/tile_break.png # 输出路径(必填)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
86
|
+
| ---------- | ------ | ---------- | -------------------- |
|
|
87
|
+
| `--preset` | string | 必填 | VFX 预设名 |
|
|
88
|
+
| `--output` | string | 必填 | 输出精灵表路径(.png) |
|
|
89
|
+
| `--tint` | hex | 预设默认色 | 颜色叠加 `#RRGGBB` |
|
|
90
|
+
| `--scale` | number | 1.0 | 整体缩放(0.5-3.0) |
|
|
91
|
+
|
|
92
|
+
### animate 完整示例
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
playcraft image animate \
|
|
96
|
+
--input assets/images/ui/cta_button.png \ # 输入静态素材(必填)
|
|
97
|
+
--preset pulse \ # 动画预设(默认bounce)
|
|
98
|
+
--frames 8 \ # 总帧数(2-64, 默认8)
|
|
99
|
+
--columns 4 \ # 精灵表列数(默认4)
|
|
100
|
+
--output assets/images/ui/cta_button_pulse.png # 输出路径(必填)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
104
|
+
| ----------- | ------ | ------ | ----------------------- |
|
|
105
|
+
| `--input` | string | 必填 | 输入图片路径 |
|
|
106
|
+
| `--output` | string | 必填 | 输出精灵表路径(.png) |
|
|
107
|
+
| `--preset` | string | bounce | 动画预设名 |
|
|
108
|
+
| `--frames` | number | 8 | 总帧数(2-64) |
|
|
109
|
+
| `--columns` | number | 4 | 精灵表列数 |
|
|
110
|
+
| `--back` | string | 无 | flip 专用: 背面图片路径 |
|
|
111
|
+
|
|
112
|
+
## 4. Post-Generation Checklist
|
|
113
|
+
|
|
114
|
+
| 检查项 | 方法 | 不通过时 |
|
|
115
|
+
| ------------------ | ---------------------------------- | ---------------------------- |
|
|
116
|
+
| 帧数与预设规格匹配 | 计算精灵表格子数 = 行x列 | 重新生成, 检查 --frames 参数 |
|
|
117
|
+
| 精灵表尺寸合理 | 单帧 <= 256x256, 总图 <= 1024px 宽 | 降低 --scale 或减少帧数 |
|
|
118
|
+
| 文件体积在预算内 | VFX 总计 <= 150KB | 减少预设数量或降帧 |
|
|
119
|
+
| 记录到 ta-log.md | grid 参数(帧数/列数/单帧尺寸) | 补写, Developer 需要此信息 |
|
|
120
|
+
|
|
121
|
+
## 5. Detailed Reference
|
|
122
|
+
|
|
123
|
+
完整预设目录与组合配方见 `refs/ta-vfx-preset-catalog.md`,包含:
|
|
124
|
+
|
|
125
|
+
- 每个 VFX 预设的完整详解(动画感描述、Tint 建议、Scale 建议、典型错误)
|
|
126
|
+
- 每个 animate 预设的完整详解(参数建议、最佳用途、典型错误)
|
|
127
|
+
- 按游戏类型的 VFX + 动画组合配方(Match-3 / 跑酷 / 卡牌 / 泡泡射击)
|
|
128
|
+
- flip 工作流详情
|
|
129
|
+
- 自定义帧数决策指南与非均匀帧时长技巧
|
|
130
|
+
- 体积预算分配参考
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playwright-cli
|
|
3
|
+
description: Automate browser interactions, test web pages and work with Playwright tests.
|
|
4
|
+
allowed-tools: Bash(playwright-cli:*) Bash(npx:*) Bash(npm:*)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Browser Automation with playwright-cli
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# open new browser
|
|
13
|
+
playwright-cli open
|
|
14
|
+
# navigate to a page
|
|
15
|
+
playwright-cli goto https://playwright.dev
|
|
16
|
+
# interact with the page using refs from the snapshot
|
|
17
|
+
playwright-cli click e15
|
|
18
|
+
playwright-cli type "page.click"
|
|
19
|
+
playwright-cli press Enter
|
|
20
|
+
# take a screenshot (rarely used, as snapshot is more common)
|
|
21
|
+
playwright-cli screenshot
|
|
22
|
+
# close the browser
|
|
23
|
+
playwright-cli close
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Commands
|
|
27
|
+
|
|
28
|
+
### Core
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
playwright-cli open
|
|
32
|
+
# open and navigate right away
|
|
33
|
+
playwright-cli open https://example.com/
|
|
34
|
+
playwright-cli goto https://playwright.dev
|
|
35
|
+
playwright-cli type "search query"
|
|
36
|
+
playwright-cli click e3
|
|
37
|
+
playwright-cli dblclick e7
|
|
38
|
+
# --submit presses Enter after filling the element
|
|
39
|
+
playwright-cli fill e5 "user@example.com" --submit
|
|
40
|
+
playwright-cli drag e2 e8
|
|
41
|
+
# drop files or data onto an element (from outside the page)
|
|
42
|
+
playwright-cli drop e4 --path=./image.png
|
|
43
|
+
playwright-cli drop e4 --data="text/plain=hello world"
|
|
44
|
+
playwright-cli hover e4
|
|
45
|
+
playwright-cli select e9 "option-value"
|
|
46
|
+
playwright-cli upload ./document.pdf
|
|
47
|
+
playwright-cli check e12
|
|
48
|
+
playwright-cli uncheck e12
|
|
49
|
+
playwright-cli snapshot
|
|
50
|
+
playwright-cli eval "document.title"
|
|
51
|
+
playwright-cli eval "el => el.textContent" e5
|
|
52
|
+
# get element id, class, or any attribute not visible in the snapshot
|
|
53
|
+
playwright-cli eval "el => el.id" e5
|
|
54
|
+
playwright-cli eval "el => el.getAttribute('data-testid')" e5
|
|
55
|
+
playwright-cli dialog-accept
|
|
56
|
+
playwright-cli dialog-accept "confirmation text"
|
|
57
|
+
playwright-cli dialog-dismiss
|
|
58
|
+
playwright-cli resize 1920 1080
|
|
59
|
+
playwright-cli close
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Navigation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
playwright-cli go-back
|
|
66
|
+
playwright-cli go-forward
|
|
67
|
+
playwright-cli reload
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Keyboard
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
playwright-cli press Enter
|
|
74
|
+
playwright-cli press ArrowDown
|
|
75
|
+
playwright-cli keydown Shift
|
|
76
|
+
playwright-cli keyup Shift
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Mouse
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
playwright-cli mousemove 150 300
|
|
83
|
+
playwright-cli mousedown
|
|
84
|
+
playwright-cli mousedown right
|
|
85
|
+
playwright-cli mouseup
|
|
86
|
+
playwright-cli mouseup right
|
|
87
|
+
playwright-cli mousewheel 0 100
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Save as
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
playwright-cli screenshot
|
|
94
|
+
playwright-cli screenshot e5
|
|
95
|
+
playwright-cli screenshot --filename=page.png
|
|
96
|
+
playwright-cli pdf --filename=page.pdf
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Tabs
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
playwright-cli tab-list
|
|
103
|
+
playwright-cli tab-new
|
|
104
|
+
playwright-cli tab-new https://example.com/page
|
|
105
|
+
playwright-cli tab-close
|
|
106
|
+
playwright-cli tab-close 2
|
|
107
|
+
playwright-cli tab-select 0
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Storage
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
playwright-cli state-save
|
|
114
|
+
playwright-cli state-save auth.json
|
|
115
|
+
playwright-cli state-load auth.json
|
|
116
|
+
|
|
117
|
+
# Cookies
|
|
118
|
+
playwright-cli cookie-list
|
|
119
|
+
playwright-cli cookie-list --domain=example.com
|
|
120
|
+
playwright-cli cookie-get session_id
|
|
121
|
+
playwright-cli cookie-set session_id abc123
|
|
122
|
+
playwright-cli cookie-set session_id abc123 --domain=example.com --httpOnly --secure
|
|
123
|
+
playwright-cli cookie-delete session_id
|
|
124
|
+
playwright-cli cookie-clear
|
|
125
|
+
|
|
126
|
+
# LocalStorage
|
|
127
|
+
playwright-cli localstorage-list
|
|
128
|
+
playwright-cli localstorage-get theme
|
|
129
|
+
playwright-cli localstorage-set theme dark
|
|
130
|
+
playwright-cli localstorage-delete theme
|
|
131
|
+
playwright-cli localstorage-clear
|
|
132
|
+
|
|
133
|
+
# SessionStorage
|
|
134
|
+
playwright-cli sessionstorage-list
|
|
135
|
+
playwright-cli sessionstorage-get step
|
|
136
|
+
playwright-cli sessionstorage-set step 3
|
|
137
|
+
playwright-cli sessionstorage-delete step
|
|
138
|
+
playwright-cli sessionstorage-clear
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Network
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
playwright-cli route "**/*.jpg" --status=404
|
|
145
|
+
playwright-cli route "https://api.example.com/**" --body='{"mock": true}'
|
|
146
|
+
playwright-cli route-list
|
|
147
|
+
playwright-cli unroute "**/*.jpg"
|
|
148
|
+
playwright-cli unroute
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### DevTools
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
playwright-cli console
|
|
155
|
+
playwright-cli console warning
|
|
156
|
+
playwright-cli requests
|
|
157
|
+
playwright-cli request 5
|
|
158
|
+
playwright-cli run-code "async page => await page.context().grantPermissions(['geolocation'])"
|
|
159
|
+
playwright-cli run-code --filename=script.js
|
|
160
|
+
playwright-cli tracing-start
|
|
161
|
+
playwright-cli tracing-stop
|
|
162
|
+
playwright-cli video-start video.webm
|
|
163
|
+
playwright-cli video-chapter "Chapter Title" --description="Details" --duration=2000
|
|
164
|
+
playwright-cli video-stop
|
|
165
|
+
|
|
166
|
+
# launch the dashboard for UI review / design feedback — user annotates the page, you receive the annotated screenshot, snapshot, and notes
|
|
167
|
+
playwright-cli show --annotate
|
|
168
|
+
|
|
169
|
+
# generate a Playwright locator for an element from its ref or selector
|
|
170
|
+
playwright-cli generate-locator e5 --raw
|
|
171
|
+
|
|
172
|
+
# show a persistent highlight overlay for an element, optionally with a custom style
|
|
173
|
+
playwright-cli highlight e5
|
|
174
|
+
playwright-cli highlight e5 --style="outline: 3px dashed red"
|
|
175
|
+
# hide a single element highlight, or all page highlights when no target is given
|
|
176
|
+
playwright-cli highlight e5 --hide
|
|
177
|
+
playwright-cli highlight --hide
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Raw output
|
|
181
|
+
|
|
182
|
+
The global `--raw` option strips page status, generated code, and snapshot sections from the output, returning only the result value. Use it to pipe command output into other tools. Commands that don't produce output return nothing.
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
playwright-cli --raw eval "JSON.stringify(performance.timing)" | jq '.loadEventEnd - .navigationStart'
|
|
186
|
+
playwright-cli --raw eval "JSON.stringify([...document.querySelectorAll('a')].map(a => a.href))" > links.json
|
|
187
|
+
playwright-cli --raw snapshot > before.yml
|
|
188
|
+
playwright-cli click e5
|
|
189
|
+
playwright-cli --raw snapshot > after.yml
|
|
190
|
+
diff before.yml after.yml
|
|
191
|
+
TOKEN=$(playwright-cli --raw cookie-get session_id)
|
|
192
|
+
playwright-cli --raw localstorage-get theme
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
For structured output wrapping every reply as JSON, pass --json
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
playwright-cli list --json
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Open parameters
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# Use specific browser when creating session
|
|
205
|
+
playwright-cli open --browser=chrome
|
|
206
|
+
playwright-cli open --browser=firefox
|
|
207
|
+
playwright-cli open --browser=webkit
|
|
208
|
+
playwright-cli open --browser=msedge
|
|
209
|
+
|
|
210
|
+
# Use persistent profile (by default profile is in-memory)
|
|
211
|
+
playwright-cli open --persistent
|
|
212
|
+
# Use persistent profile with custom directory
|
|
213
|
+
playwright-cli open --profile=/path/to/profile
|
|
214
|
+
|
|
215
|
+
# Connect to browser via Playwright Extension
|
|
216
|
+
playwright-cli attach --extension=chrome
|
|
217
|
+
|
|
218
|
+
# Connect to a running Chrome or Edge by channel name
|
|
219
|
+
playwright-cli attach --cdp=chrome
|
|
220
|
+
playwright-cli attach --cdp=msedge
|
|
221
|
+
|
|
222
|
+
# Connect to a running browser via CDP endpoint
|
|
223
|
+
playwright-cli attach --cdp=http://localhost:9222
|
|
224
|
+
|
|
225
|
+
# Start with config file
|
|
226
|
+
playwright-cli open --config=my-config.json
|
|
227
|
+
|
|
228
|
+
# Close the browser
|
|
229
|
+
playwright-cli close
|
|
230
|
+
# Detach from an attached browser (leaves the external browser running)
|
|
231
|
+
playwright-cli -s=msedge detach
|
|
232
|
+
# Delete user data for the default session
|
|
233
|
+
playwright-cli delete-data
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Snapshots
|
|
237
|
+
|
|
238
|
+
After each command, playwright-cli provides a snapshot of the current browser state.
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
> playwright-cli goto https://example.com
|
|
242
|
+
### Page
|
|
243
|
+
- Page URL: https://example.com/
|
|
244
|
+
- Page Title: Example Domain
|
|
245
|
+
### Snapshot
|
|
246
|
+
[Snapshot](.playwright-cli/page-2026-02-14T19-22-42-679Z.yml)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
You can also take a snapshot on demand using `playwright-cli snapshot` command. All the options below can be combined as needed.
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# default - save to a file with timestamp-based name
|
|
253
|
+
playwright-cli snapshot
|
|
254
|
+
|
|
255
|
+
# save to file, use when snapshot is a part of the workflow result
|
|
256
|
+
playwright-cli snapshot --filename=after-click.yaml
|
|
257
|
+
|
|
258
|
+
# snapshot an element instead of the whole page
|
|
259
|
+
playwright-cli snapshot "#main"
|
|
260
|
+
|
|
261
|
+
# limit snapshot depth for efficiency, take a partial snapshot afterwards
|
|
262
|
+
playwright-cli snapshot --depth=4
|
|
263
|
+
playwright-cli snapshot e34
|
|
264
|
+
|
|
265
|
+
# include each element's bounding box as [box=x,y,width,height]
|
|
266
|
+
playwright-cli snapshot --boxes
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Targeting elements
|
|
270
|
+
|
|
271
|
+
By default, use refs from the snapshot to interact with page elements.
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# get snapshot with refs
|
|
275
|
+
playwright-cli snapshot
|
|
276
|
+
|
|
277
|
+
# interact using a ref
|
|
278
|
+
playwright-cli click e15
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
You can also use css selectors or Playwright locators.
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
# css selector
|
|
285
|
+
playwright-cli click "#main > button.submit"
|
|
286
|
+
|
|
287
|
+
# role locator
|
|
288
|
+
playwright-cli click "getByRole('button', { name: 'Submit' })"
|
|
289
|
+
|
|
290
|
+
# test id
|
|
291
|
+
playwright-cli click "getByTestId('submit-button')"
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Browser Sessions
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
# create new browser session named "mysession" with persistent profile
|
|
298
|
+
playwright-cli -s=mysession open example.com --persistent
|
|
299
|
+
# same with manually specified profile directory (use when requested explicitly)
|
|
300
|
+
playwright-cli -s=mysession open example.com --profile=/path/to/profile
|
|
301
|
+
playwright-cli -s=mysession click e6
|
|
302
|
+
playwright-cli -s=mysession close # stop a named browser
|
|
303
|
+
playwright-cli -s=mysession delete-data # delete user data for persistent session
|
|
304
|
+
|
|
305
|
+
playwright-cli list
|
|
306
|
+
# Close all browsers
|
|
307
|
+
playwright-cli close-all
|
|
308
|
+
# Forcefully kill all browser processes
|
|
309
|
+
playwright-cli kill-all
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Installation
|
|
313
|
+
|
|
314
|
+
If global `playwright-cli` command is not available, try a local version via `npx playwright-cli`:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
npx --no-install playwright-cli --version
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
When local version is available, use `npx playwright-cli` in all commands. Otherwise, install `playwright-cli` as a global command:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
npm install -g @playwright/cli@latest
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## Example: Form submission
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
playwright-cli open https://example.com/form
|
|
330
|
+
playwright-cli snapshot
|
|
331
|
+
|
|
332
|
+
playwright-cli fill e1 "user@example.com"
|
|
333
|
+
playwright-cli fill e2 "password123"
|
|
334
|
+
playwright-cli click e3
|
|
335
|
+
playwright-cli snapshot
|
|
336
|
+
playwright-cli close
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Example: Multi-tab workflow
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
playwright-cli open https://example.com
|
|
343
|
+
playwright-cli tab-new https://example.com/other
|
|
344
|
+
playwright-cli tab-list
|
|
345
|
+
playwright-cli tab-select 0
|
|
346
|
+
playwright-cli snapshot
|
|
347
|
+
playwright-cli close
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Example: Debugging with DevTools
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
playwright-cli open https://example.com
|
|
354
|
+
playwright-cli click e4
|
|
355
|
+
playwright-cli fill e7 "test"
|
|
356
|
+
playwright-cli console
|
|
357
|
+
playwright-cli requests
|
|
358
|
+
playwright-cli close
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
playwright-cli open https://example.com
|
|
363
|
+
playwright-cli tracing-start
|
|
364
|
+
playwright-cli click e4
|
|
365
|
+
playwright-cli fill e7 "test"
|
|
366
|
+
playwright-cli tracing-stop
|
|
367
|
+
playwright-cli close
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## Example: Interactive session
|
|
371
|
+
|
|
372
|
+
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":
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
playwright-cli open https://example.com
|
|
376
|
+
playwright-cli show --annotate
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## Specific tasks
|
|
380
|
+
|
|
381
|
+
- **Running and Debugging Playwright tests** [references/playwright-tests.md](references/playwright-tests.md)
|
|
382
|
+
- **Request mocking** [references/request-mocking.md](references/request-mocking.md)
|
|
383
|
+
- **Running Playwright code** [references/running-code.md](references/running-code.md)
|
|
384
|
+
- **Browser session management** [references/session-management.md](references/session-management.md)
|
|
385
|
+
- **Spec-driven testing (plan / generate / heal)** [references/spec-driven-testing.md](references/spec-driven-testing.md)
|
|
386
|
+
- **Storage state (cookies, localStorage)** [references/storage-state.md](references/storage-state.md)
|
|
387
|
+
- **Test generation** [references/test-generation.md](references/test-generation.md)
|
|
388
|
+
- **Tracing** [references/tracing.md](references/tracing.md)
|
|
389
|
+
- **Video recording** [references/video-recording.md](references/video-recording.md)
|
|
390
|
+
- **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
|
+
```
|