SSW E2E Test Skill
E2E testing toolkit for jnpf low-code platform using Playwright.
Installation
Prerequisite: Install webapp-testing skill first (ssw-e2e-test extends it):
# Clone webapp-testing skill
cd ~/.claude/skills
git clone https://github.com/anthropics/skills.git temp_skills
cp -r temp_skills/skills/webapp-testing .
rm -rf temp_skills
# Or manually download from:
# https://github.com/anthropics/skills/tree/main/skills/webapp-testing
Configuration
IMPORTANT: All configuration is via environment variables. Do not hardcode values.
# Required
export JNPF_HOST="192.168.1.18:13880" # jnpf server address
export JNPF_APP_CODE="dr" # app code (dr, workSystem, etc.)
export JNPF_USERNAME="admin" # username
export JNPF_PASSWORD="123456" # password
# Optional
export JNPF_TEMP_DIR="/tmp/jnpf_test" # temp directory
Structure
ssw-e2e-test/
├── SKILL.md # Main skill documentation
├── README.md # This file
├── LICENSE.txt # MIT License
├── scripts/
│ ├── config.py # Configuration loader (env vars)
│ ├── dacli_web_session.py # Web session login/restore (v0.11+ 保留)
│ ├── jnpf_browser_e2e.py # Browser E2E helper (v0.11+ 保留)
│ ├── lib/ # TS/Python 双语言标准库 (v0.11+ 保留)
│ └── with_server.py # Server lifecycle (from webapp-testing)
├── examples/
│ ├── real_crud_test.py # Full CRUD workflow
│ ├── use_vxe_selectors.py # vxe-table selector patterns
│ ├── explore_login_and_menu.py # Login + menu exploration
│ └── analyze_add_modal.py # Form field analysis
└── docs/
└── 平台测试方法.md # Platform testing methodology
Quick Start
from scripts.config import get_config
from scripts.jnpf_client import JnpfClient
# Load configuration
config = get_config()
# Use client
with JnpfClient() as client:
client.login()
client.click_menu("数据资产台账")
client.crud.add("资产名称", "测试数据")
Run Examples
# Set environment variables first
export JNPF_HOST="192.168.1.18:13880"
export JNPF_APP_CODE="dr"
export JNPF_USERNAME="admin"
export JNPF_PASSWORD="123456"
# Run CRUD test
python examples/real_crud_test.py
# Run menu exploration
python examples/explore_login_and_menu.py
Key Patterns
| Pattern | Selector |
|---|---|
| vxe-table rows | .vxe-body--row |
| Modal form | .ant-modal |
| Delete confirm | .ant-modal-confirm |
| Menu items | .jnpf-menu-item |
| Click hidden element | page.evaluate('el => el.click()', handle) |
| Dropdown (ant-select) | .ant-select + .ant-select-dropdown:visible |
| Form field by ID | input#f_field_name |
| Form field by label | input[fullname="字段名称"] |
API Testing
Token 通过 UI 登录自动获取,然后可用于 API 请求:
# See docs/api-testing.md for full API patterns
import os
from docs.api_testing import JnpfApiClient
# 方式1: 自动 UI 登录获取 token
client = JnpfApiClient.from_ui_login(
host=os.environ["JNPF_HOST"],
app_code=os.environ["JNPF_APP_CODE"]
)
# 方式2: 手动传入已获取的 token
client = JnpfApiClient(
host=os.environ["JNPF_HOST"],
app_code=os.environ["JNPF_APP_CODE"],
token="bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
)
# API 查询
result = client.query_list(model_id, menu_id)
print(f"Total: {result['data']['pagination']['total']}")
Hybrid approach: Use UI for login/navigation, API for data operations.
Critical Patterns Discovered Through Testing
1. Dropdown Selection (ant-select)
# Click the dropdown trigger
page.evaluate('el => el.click()', selects[0].element_handle())
time.sleep(1)
# Wait for and click the option
dropdown = page.locator('.ant-select-dropdown:visible')
dropdown.first.locator('.ant-select-item').nth(0).click()
2. Form Field Identification
# Fields have fullname attribute with Chinese label
input#f_asset_name
input#f_category_code
input#f_applicant
# Or use placeholder
input[placeholder="请输入申请人"]
3. Save Success Detection
# CRITICAL: Check BOTH modal closed AND data saved
initial_count = page.locator('.vxe-body--row').count()
save_btn.click()
time.sleep(3)
modal_closed = page.locator('.ant-modal').count() == 0
data_saved = page.locator('.vxe-body--row').count() > initial_count
if not modal_closed and data_saved:
# This happens! Modal stays open but data IS saved
print("Save succeeded but modal didn't close")
Known Issues
| Issue | Workaround |
|---|---|
| Dropdown click intercepted | Use JS click via page.evaluate() |
| Modal doesn't close after save | Check data saved, not just modal state |
| Unknown form field IDs | Use fullname attribute or explore modal first |
| Partial menu text matches many | Use exact menu name |
Dependencies
- playwright
- Python 3.8+