add-regression-point
为已有 PageObject 增量添加回归测试点。触发:新增测试点、添加回归点、add test point、增加覆盖、扩展页面方法。
POM 分层与 context 共享决策树。触发:架构、分层、POM、Page Object、基类设计、新增角色。
$ npx -y skills add danielsuo117/velocitai --skill architecture --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/architectureContext preview
The summary Claude sees to decide when to auto-load this skill.
POM 分层与 context 共享决策树。触发:架构、分层、POM、Page Object、基类设计、新增角色。
name: architecture description: POM 分层与 context 共享决策树。触发:架构、分层、POM、Page Object、基类设计、新增角色。
---
┌─────────────────────────────────────────────┐ │ tests/ 测试层 │ │ 按角色拆分文件:test_<role>_flow.py │ │ 每个测试类继承 Base(或 Role-Base) │ ├─────────────────────────────────────────────┤ │ pages/ 页面对象层 │ │ Base ← Login ← Landing ← Detail / ... │ │ 通用 Role 用前缀命名:Role<Role><Page>Page │ ├─────────────────────────────────────────────┤ │ config/ 配置层 │ │ URL、Token、浏览器参数按环境切换 │ ├─────────────────────────────────────────────┤ │ conftest.py Fixture 层 │ │ browser → context → page → Role-specific base │ └─────────────────────────────────────────────┘
**数据流向**:`config` → `conftest`(读取配置创建 fixture) → `pages`(接收 page 对象) → `tests`(组合页面对象执行断言)
---
# 页面名称:<中文名>
from core.base.base_page import BasePage
class <PageName>(BasePage):
# 定位符常量(类顶部)
<LOCATOR_CONSTANT> = "<selector>" # P<0-5>: 说明
PAGE_IDENTIFIER = "<selector>" # 页面加载锚点
# 业务方法(前缀:click_ / fill_ / select_ / get_xxx_text / wait_for_ / is_xxx_visible)
def click_<action>(self):
self.click(self.<LOCATOR_CONSTANT>)
# 页面加载验证(必须实现,放在最后)
def is_page_loaded(self) -> bool:
return self.is_visible(self.PAGE_IDENTIFIER)---
一组用例是否满足以下 3 条?
1. 同一域名(不跨端)
2. 有统一前置(登录、角色切换…)
3. 有统一起点页面(可复位)
│
├─ 是(三条全满足)
│ └→ class 级共享 context
│ - 用 scope="class" 的 page fixture(实现见 browser-config skill)
│ - 专用基类:class setup 完成前置;function-scope autouse 复位起点
│ - 用例末尾必须往返闭合(见 case-round-trip skill)
│
└─ 否(任一不满足)
└→ function 级独立 context
- 每用例独立 browser.new_context() + new_page()
- 每用例独立登录**注意事项:**
---
同一 class 的多个用例之间接力同一页面状态(避免每个用例重新登录导航)的 实现要点、骨架与适用条件 → [references/page-relay-pattern.md](./references/page-relay-pattern.md)
1. 决策:用上面的决策树判断新 Role 的用例是否可共享 context 2. PageObject:以 `Role<Role><Page>Page` 命名、`role_<page>` 文件名前缀,继承 `BasePage` 3. 基类(若采用 class 级共享):新建 `tests/<role>/<role>_base_test.py::<Role>BaseTest` 继承 `BaseTest`,实现登录 + 切换 + 起点断言 4. 用例:`tests/<role>/test_<role>_flow.py::Test<Role>Flow` 继承新基类 5. 文档:在 [docs/architecture.md](../../docs/architecture.md) 表中追加一行 6. 目录:`pages/__init__.py` 追加新页面导出
---
本项目当前的落地情况(具体类名、fixture、起点页面)→ [docs/architecture.md](../../docs/architecture.md)。
Next-generation UI automation harness powered by Python & Playwright. Chat with AI Agents to seamlessly generate, architect, and execute enterprise-grade UI test code.
为已有 PageObject 增量添加回归测试点。触发:新增测试点、添加回归点、add test point、增加覆盖、扩展页面方法。
浏览器 viewport / headless / 超时分层配置。触发:viewport、浏览器配置、导航超时、headless、slow_mo、incognito。
共享 page 下用例离开起点后必须 UI 返回并断言。触发:往返闭合、case round trip、复位超时、scope 共享 page。
一键生成 PageObject + 配套测试。触发:新增页面、生成页面、gen page、create page、添加页面对象。
替换占位定位符为真实选择器(六级优先级)。触发:替换定位符、locator、selector、定位失败、元素找不到、DOM 分析。