Files
claude-config/skills/ssw-e2e-test/scripts/lib/__init__.py
T
ssw 54b3e01d13 v18: 6 进阶组件 helper Python 镜像 (form.py + __init__.py)
镜像 TS 版 6 新 helper:
- fillDateRangeByLabel (dateRange picker)
- toggleSwitchByLabel (开关 on/off/toggle, aria-checked 检测)
- selectRadioByLabel (radio group 按 index)
- checkCheckboxByLabel (checkbox group 按 index)
- selectTreeByLabel (treeSelect 按节点文字)
- uploadFileByLabel (file upload via set_input_files)

Python lib form.py: 147 → 280 行 (+133)
__init__.py: 40 → 46 行 (+6 exports)

typecheck 干净 (ast.parse OK)
2026-06-15 18:00:35 +08:00

47 lines
2.4 KiB
Python

"""
ssw-e2e-test/scripts/lib — JNPF 浏览器验证标准库 (Python 镜像)
用法:
from lib import clickMenu, fillByLabel, saveModal, countRows, clickAdd
模块清单 (与 dacli/tests/e2e/_helpers/ 一一对应):
- selectors.py 选择器常量 (SEL / formItemByLabel / rowAction)
- wait.py 智能等待 (waitSpaReady / waitTableReady / waitFormModalReady / waitRowCountChange)
- nav.py 菜单导航 (clickMenu / expandCategory)
- form.py 表单操作 (fillByLabel / selectByLabel / fillDateByLabel / fillTextareaByLabel /
fillNumberByLabel / saveModal / closeModal)
- table.py vxe-table (countRows / findRow / clickRowAction / getTotalText / clickAdd)
- modal.py 模态框 (waitOpen / waitClose / getErrors / isOpen / getTitle)
- auth.py (放在 scripts/dacli_web_session.py, 单独用)
设计原则:
- 与 TS 版 API 尽量对齐 (camelCase 一致), Python 风格 + 双驼峰兼容
- 错误显式抛 (RuntimeError), 不静默, 方便脚本中断定位
- 走 Playwright sync API (与 jnpf_browser_e2e.py 风格一致)
"""
from .selectors import SEL, formItemByLabel, rowAction
from .wait import waitSpaReady, waitTableReady, waitFormModalReady, waitModalClose, waitRowCountChange
from .nav import clickMenu, expandCategory
from .form import (
fillByLabel, selectByLabel, fillDateByLabel, fillTextareaByLabel,
fillNumberByLabel, saveModal, closeModal,
# v18+ 进阶组件
fillDateRangeByLabel, toggleSwitchByLabel, selectRadioByLabel,
checkCheckboxByLabel, selectTreeByLabel, uploadFileByLabel,
)
from .table import countRows, findRow, clickRowAction as _clickRowAction, getTotalText, getTotalCount, clickAdd
from .modal import waitOpen, waitClose, getErrors, isOpen, getTitle
__all__ = [
"SEL", "formItemByLabel", "rowAction",
"waitSpaReady", "waitTableReady", "waitFormModalReady", "waitModalClose", "waitRowCountChange",
"clickMenu", "expandCategory",
"fillByLabel", "selectByLabel", "fillDateByLabel", "fillTextareaByLabel",
"fillNumberByLabel", "saveModal", "closeModal",
# v18+ 进阶
"fillDateRangeByLabel", "toggleSwitchByLabel", "selectRadioByLabel",
"checkCheckboxByLabel", "selectTreeByLabel", "uploadFileByLabel",
"countRows", "findRow", "clickRowAction", "getTotalText", "getTotalCount", "clickAdd",
"waitOpen", "waitClose", "getErrors", "isOpen", "getTitle",
]