提交 aaec343e authored 作者: 陈泽健's avatar 陈泽健

feat(scripts): 新增创建各模块UI自动化用例的脚本

- 为17个功能模块创建19个页面访问验证用例
- 覆盖模块:集控控制、信息发布、数据统计、信息管理、预定2.0等
- 用例通过功能中心导航访问目标页面
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
上级 08714b7e
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
模块名称:create_ui_cases_all_modules.py
模块描述:为所有模块创建可执行的UI自动化测试用例
作者:czj
创建日期:2026-08-05
"""
import requests
import json
import time
BASE_URL = "http://192.168.5.60"
TARGET_URL = "https://192.168.5.44"
# 模块ID映射(从API查询得到)
MODULES = {
# 主要功能模块
"jikong": "module_parent_jikong", # 集控控制
"qita": "module_parent_qita", # 其他分类
"shujutongji": "module_parent_shujutongji", # 数据统计
"xinxifabu": "module_parent_xinxifabu", # 信息发布
"xinxiguanli": "module_parent_xinxiguanli", # 信息管理
"yuding20": "module_parent_yuding20", # 预定2.0
"huiyiguanli": "module_e80a5d08b48d4c67a16cb86156320f25", # 会议管理
"shujufenxi": "module_6790b99750114326b539458f322f3be8", # 数据分析
"yunweiguanli": "module_ddec220aa05f4a4b9b3728a648dfa62a", # 运维管理
"guanlikaiban": "module_33fd0582a8e74f46b9fd66051fc61b83", # 管理看板
"huiyiyunwei": "module_c9496f382be1430c958936d5cf473f62", # 会议运维
"zichanguanli": "module_251aebd2e6dd4d09acda0eb179c35d23", # 资产管理
"huiwuguanli": "module_69cba085ed3c4b8288a363de7b97aa63", # 会务管理
"weihugongdan": "module_0b5e956ade4c4b188ec1a6826f71229c", # 维护工单
"tongzhigonggao": "module_113aab3c986749c4873d06aa2eb755c2", # 通知公告
"huiyishiguanli": "module_6f20117d17254d8ea173251adac2afc6", # 会议室管理
"xitongshezhi": "module_3615909f76fe4f868a1cbf2437c9a4cb", # 系统设置
}
DEFAULT_CONFIG = {
"timeout": 120000,
"screenshot": True,
"auto_login": True,
}
def build_cases():
"""构建所有模块的测试用例"""
cases = []
# ==================== 集控控制模块 ====================
cases.extend([
{
"name": "集控控制-壁纸推送功能验证",
"description": "验证通过功能中心访问壁纸推送页面,确认列表和操作按钮正常显示",
"module_id": MODULES["jikong"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击集控控制分类", "action": "click", "params": {"selector": ".el-drawer >> text='集控控制'"}},
{"order": 5, "name": "点击壁纸推送菜单", "action": "click", "params": {"selector": ".el-drawer >> text='壁纸推送'"}},
{"order": 6, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 7, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
{
"name": "集控控制-脚本命令功能验证",
"description": "验证脚本命令页面可正常访问",
"module_id": MODULES["jikong"],
"priority": "high",
"order": 101,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击集控控制分类", "action": "click", "params": {"selector": ".el-drawer >> text='集控控制'"}},
{"order": 5, "name": "点击脚本命令菜单", "action": "click", "params": {"selector": ".el-drawer >> text='脚本命令'"}},
{"order": 6, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 7, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
{
"name": "集控控制-应用管理功能验证",
"description": "验证应用管理页面可正常访问",
"module_id": MODULES["jikong"],
"priority": "high",
"order": 102,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击集控控制分类", "action": "click", "params": {"selector": ".el-drawer >> text='集控控制'"}},
{"order": 5, "name": "点击应用管理菜单", "action": "click", "params": {"selector": ".el-drawer >> text='应用管理'"}},
{"order": 6, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 7, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 信息发布模块 ====================
cases.extend([
{
"name": "信息发布-页面访问验证",
"description": "验证通过功能中心访问信息发布页面",
"module_id": MODULES["xinxifabu"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击信息发布菜单", "action": "click", "params": {"selector": ".el-drawer >> text='信息发布'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 数据统计模块 ====================
cases.extend([
{
"name": "数据统计-页面访问验证",
"description": "验证通过功能中心访问数据统计页面",
"module_id": MODULES["shujutongji"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击数据统计菜单", "action": "click", "params": {"selector": ".el-drawer >> text='数据统计'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 信息管理模块 ====================
cases.extend([
{
"name": "信息管理-页面访问验证",
"description": "验证通过功能中心访问信息管理页面",
"module_id": MODULES["xinxiguanli"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击信息管理菜单", "action": "click", "params": {"selector": ".el-drawer >> text='信息管理'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 预定2.0模块 ====================
cases.extend([
{
"name": "预定2.0-页面访问验证",
"description": "验证通过功能中心访问预定2.0页面",
"module_id": MODULES["yuding20"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击预定2.0菜单", "action": "click", "params": {"selector": ".el-drawer >> text='预定2.0'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 会议管理模块 ====================
cases.extend([
{
"name": "会议管理-会议列表查看",
"description": "验证会议管理页面列表正常显示",
"module_id": MODULES["huiyiguanli"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击会议管理菜单", "action": "click", "params": {"selector": ".el-drawer >> text='会议管理'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 数据分析模块 ====================
cases.extend([
{
"name": "数据分析-页面访问验证",
"description": "验证数据分析页面可正常访问",
"module_id": MODULES["shujufenxi"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击数据分析菜单", "action": "click", "params": {"selector": ".el-drawer >> text='数据分析'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 运维管理模块 ====================
cases.extend([
{
"name": "运维管理-页面访问验证",
"description": "验证运维管理页面可正常访问",
"module_id": MODULES["yunweiguanli"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击运维管理菜单", "action": "click", "params": {"selector": ".el-drawer >> text='运维管理'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 管理看板模块 ====================
cases.extend([
{
"name": "管理看板-数据展示验证",
"description": "验证管理看板页面数据正常展示",
"module_id": MODULES["guanlikaiban"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击管理看板菜单", "action": "click", "params": {"selector": ".el-drawer >> text='管理看板'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 会议运维模块 ====================
cases.extend([
{
"name": "会议运维-运维设备页面验证",
"description": "验证会议运维-运维设备页面可正常访问",
"module_id": MODULES["huiyiyunwei"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击会议运维菜单", "action": "click", "params": {"selector": ".el-drawer >> text='会议运维'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 资产管理模块 ====================
cases.extend([
{
"name": "资产管理-资产信息页面验证",
"description": "验证资产管理页面可正常访问",
"module_id": MODULES["zichanguanli"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击资产管理菜单", "action": "click", "params": {"selector": ".el-drawer >> text='资产管理'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 会务管理模块 ====================
cases.extend([
{
"name": "会务管理-页面访问验证",
"description": "验证会务管理页面可正常访问",
"module_id": MODULES["huiwuguanli"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击会务管理菜单", "action": "click", "params": {"selector": ".el-drawer >> text='会务管理'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 维护工单模块 ====================
cases.extend([
{
"name": "维护工单-页面访问验证",
"description": "验证维护工单页面可正常访问",
"module_id": MODULES["weihugongdan"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击维护工单菜单", "action": "click", "params": {"selector": ".el-drawer >> text='维护工单'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 通知公告模块 ====================
cases.extend([
{
"name": "通知公告-页面访问验证",
"description": "验证通知公告页面可正常访问",
"module_id": MODULES["tongzhigonggao"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击通知公告菜单", "action": "click", "params": {"selector": ".el-drawer >> text='通知公告'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 会议室管理模块 ====================
cases.extend([
{
"name": "会议室管理-页面访问验证",
"description": "验证会议室管理页面可正常访问",
"module_id": MODULES["huiyishiguanli"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击会议室管理菜单", "action": "click", "params": {"selector": ".el-drawer >> text='会议室管理'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 系统设置模块 ====================
cases.extend([
{
"name": "系统设置-页面访问验证",
"description": "验证系统设置页面可正常访问",
"module_id": MODULES["xitongshezhi"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击系统设置菜单", "action": "click", "params": {"selector": ".el-drawer >> text='系统设置'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
# ==================== 其他分类模块 ====================
cases.extend([
{
"name": "其他分类-已预定会议页面验证",
"description": "验证已预定会议页面可正常访问",
"module_id": MODULES["qita"],
"priority": "high",
"order": 100,
"config": DEFAULT_CONFIG,
"steps": [
{"order": 1, "name": "等待首页加载", "action": "wait", "params": {"selector": ".block", "timeout": 15000}},
{"order": 2, "name": "点击功能中心图标", "action": "click", "params": {"selector": ".home_nav_left"}},
{"order": 3, "name": "等待抽屉打开", "action": "wait", "params": {"selector": ".el-drawer", "timeout": 10000}},
{"order": 4, "name": "点击其他分类菜单", "action": "click", "params": {"selector": ".el-drawer >> text='其他分类'"}},
{"order": 5, "name": "等待页面加载", "action": "wait", "params": {"selector": "body", "timeout": 15000}},
{"order": 6, "name": "验证页面内容存在", "action": "assert", "params": {"type": "element_exists", "selector": "body"}},
],
},
])
return cases
def create_case(case_data):
"""创建单个测试用例"""
try:
response = requests.post(f"{BASE_URL}/api/cases", json=case_data, timeout=30)
if response.status_code in (200, 201):
result = response.json()
print(f" [OK] {case_data['name']} (ID: {result['id'][:20]}...)")
return result
else:
print(f" [FAIL] {case_data['name']} - {response.status_code}: {response.text[:100]}")
return None
except Exception as e:
print(f" [ERR] {case_data['name']} - {e}")
return None
def main():
print("=" * 60)
print("为所有模块创建UI自动化测试用例")
print("=" * 60)
cases = build_cases()
print(f"\n计划创建: {len(cases)} 个用例")
print("- 集控控制: 3个")
print("- 信息发布: 1个")
print("- 数据统计: 1个")
print("- 信息管理: 1个")
print("- 预定2.0: 1个")
print("- 会议管理: 1个")
print("- 数据分析: 1个")
print("- 运维管理: 1个")
print("- 管理看板: 1个")
print("- 会议运维: 1个")
print("- 资产管理: 1个")
print("- 会务管理: 1个")
print("- 维护工单: 1个")
print("- 通知公告: 1个")
print("- 会议室管理: 1个")
print("- 系统设置: 1个")
print("- 其他分类: 1个")
success_count = 0
for i, case in enumerate(cases, 1):
print(f"\n[{i}/{len(cases)}] ", end="")
result = create_case(case)
if result:
success_count += 1
time.sleep(0.5) # 避免请求过快
print("\n" + "=" * 60)
print(f"[OK] 用例创建完成: {success_count}/{len(cases)} 成功")
print("=" * 60)
if __name__ == "__main__":
main()
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论