Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
U
ubains-module-test
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
郑晓兵
ubains-module-test
Commits
ab675143
提交
ab675143
authored
2月 13, 2025
作者:
陈泽健
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加get_test_result函数通过正则匹配获取通过率、失败率以及异常率,再调用钉钉消息通知输出通过率等值。
上级
a84fc014
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
85 行增加
和
15 行删除
+85
-15
base.cpython-310.pyc
预定系统/Base/__pycache__/base.cpython-310.pyc
+0
-0
base.py
预定系统/Base/base.py
+79
-11
README.md
预定系统/README.md
+4
-2
01审批会议创建.cpython-310.pyc
预定系统/cases/会议审批/__pycache__/01审批会议创建.cpython-310.pyc
+0
-0
02审批会议操作.cpython-310.pyc
预定系统/cases/会议审批/__pycache__/02审批会议操作.cpython-310.pyc
+0
-0
定时执行功能测试.py
预定系统/定时执行功能测试.py
+2
-2
没有找到文件。
预定系统/Base/__pycache__/base.cpython-310.pyc
浏览文件 @
ab675143
No preview for this file type
预定系统/Base/base.py
浏览文件 @
ab675143
...
...
@@ -563,12 +563,12 @@ def get_latest_report_file(report_dir, base_url):
# 返回完整的URL
return
full_url
def
dingding_send_message
(
test_report_url
,
title
,
mobile
,
ding_type
):
def
dingding_send_message
(
latest_report
,
title
,
mobile
,
ding_type
):
"""
发送钉钉机器人消息
参考接口文档:https://open.dingtalk.com/document/orgapp/custom-robots-send-group-messages#title-7fs-kgs-36x
:param
test_report_url
: 测试报告链接
:param
latest_report
: 测试报告链接
:param title: 消息标题
:param text: 消息内容
:param mobile: 需要@的手机号列表
...
...
@@ -609,14 +609,21 @@ def dingding_send_message(test_report_url, title, mobile, ding_type):
# 记录最终的 Webhook URL
logging
.
info
(
f
"钉钉机器人Webhook URL: {final_webhook_url}"
)
# 调用测试结果获取函数
browser_init
(
"标准版预定系统"
)
wd
=
GSTORE
[
'wd'
]
print
(
latest_report
)
test_result
=
get_test_result
(
latest_report
,
wd
)
# 构建消息体
headers
=
{
'Content-Type'
:
'application/json'
}
message
=
{
'msgtype'
:
'link'
,
'link'
:
{
'title'
:
title
,
'messageUrl'
:
test_report_url
,
'text'
:
test_report_url
'messageUrl'
:
latest_report
,
'text'
:
f
"通过:{test_result['pass_percent']}"
+
f
"失败:{test_result['fail_percent']}"
+
f
"异常:{test_result['exception_percent']}"
,
},
"at"
:
{
"atMobiles"
:
[
mobile
],
...
...
@@ -683,7 +690,7 @@ def run_automation_test(report_title, report_url_prefix, test_case , ding_type):
get_reportfile_send_dingding
(
f
"{report_title}"
,
report_url_prefix
,
ding_type
)
def
get_reportfile_send_dingding
(
report_title
,
report_url_prefix
,
ding_type
):
print
(
GSTORE
[
'case_pass'
])
#
print(GSTORE['case_pass'])
try
:
# 获取报告文件所在的目录
report_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'..'
,
'reports'
)
...
...
@@ -1002,8 +1009,69 @@ def play_cloud_voice(app_id, app_secret, device_sn):
logging
.
error
(
f
"发生未知异常: {e}"
)
# # 示例调用
if
__name__
==
"__main__"
:
app_id
=
os
.
getenv
(
"APP_ID"
,
"a98a124c6c3252f6612fc544a0d0fa79"
)
app_secret
=
os
.
getenv
(
"APP_SECRET"
,
"88bc1ec4eba624f47b2200a4ce8c3852"
)
device_sn
=
os
.
getenv
(
"DEVICE_SN"
,
"W703BB44444"
)
play_cloud_voice
(
app_id
,
app_secret
,
device_sn
)
\ No newline at end of file
# if __name__ == "__main__":
# app_id = os.getenv("APP_ID", "a98a124c6c3252f6612fc544a0d0fa79")
# app_secret = os.getenv("APP_SECRET", "88bc1ec4eba624f47b2200a4ce8c3852")
# device_sn = os.getenv("DEVICE_SN", "W703BB44444")
# play_cloud_voice(app_id, app_secret, device_sn)
def
get_test_result
(
latest_report
,
wd
):
"""
获取测试结果页面的通过率、失败率和异常率
:param latest_report: 测试结果页面的URL
:param wd: WebDriver实例,用于访问和操作网页
:return: 包含通过率、失败率和异常率的字典
"""
# 初始化测试结果字典
test_result
=
{
"pass_percent"
:
""
,
"fail_percent"
:
""
,
"exception_percent"
:
""
}
# 访问测试结果页面
wd
.
get
(
latest_report
)
# 获取通过率
pass_percent
=
elment_get_text
((
By
.
CSS_SELECTOR
,
"div[class='result_barchart'] div:nth-child(1) span:nth-child(1)"
),
wd
)
logging
.
info
(
f
"获取的通过率:{pass_percent}"
)
match
=
re
.
search
(
r'(\d+)
%
'
,
pass_percent
)
if
match
:
pass_percent
=
match
.
group
(
0
)
else
:
pass_percent
=
"0"
test_result
[
"pass_percent"
]
=
pass_percent
# 获取失败率
fail_percent
=
elment_get_text
(
(
By
.
CSS_SELECTOR
,
"body > div.main_section > div.result > div > div:nth-child(2) > span"
),
wd
)
logging
.
info
(
f
"获取的失败率:{fail_percent}"
)
match
=
re
.
search
(
r'(\d+)
%
'
,
fail_percent
)
if
match
:
fail_percent
=
match
.
group
(
0
)
else
:
fail_percent
=
"0"
test_result
[
"fail_percent"
]
=
fail_percent
# 获取异常率
exception_percent
=
elment_get_text
(
(
By
.
CSS_SELECTOR
,
"body > div.main_section > div.result > div > div:nth-child(3) > span"
),
wd
)
logging
.
info
(
f
"获取的异常率:{exception_percent}"
)
match
=
re
.
search
(
r'(\d+)
%
'
,
exception_percent
)
if
match
:
exception_percent
=
match
.
group
(
0
)
else
:
exception_percent
=
"0"
test_result
[
"exception_percent"
]
=
exception_percent
# 返回测试结果字典
return
test_result
# if __name__ == '__main__':
# browser_init("标准版预定系统")
# wd = GSTORE['wd']
# data_result = get_test_result('http://nat.ubainsyun.com:31133/report_20250213_181722.html',wd)
# logging.info(data_result)
# print(data_result)
\ No newline at end of file
预定系统/README.md
浏览文件 @
ab675143
...
...
@@ -206,4 +206,6 @@
52.
2025-02-12
-
排查展厅巡检中的语音转录与摄像头关闭操作失效问题,原因是缺少一个返回操作,并且麦克风和摄像头的元素定位发生变化导致操作失败,缩短等待时间。
-
历史会议模块与会议审批模块补充调用清除浏览器驱动函数。
-
补充审批会议模块的日志输出。调整审批会议创建的执行步骤。
\ No newline at end of file
-
补充审批会议模块的日志输出。调整审批会议创建的执行步骤。
53.
2025-02-13
-
增加get_test_result函数通过正则匹配获取通过率、失败率以及异常率,再调用钉钉消息通知输出通过率等值。
\ No newline at end of file
预定系统/cases/会议审批/__pycache__/01审批会议创建.cpython-310.pyc
浏览文件 @
ab675143
No preview for this file type
预定系统/cases/会议审批/__pycache__/02审批会议操作.cpython-310.pyc
浏览文件 @
ab675143
No preview for this file type
预定系统/定时执行功能测试.py
浏览文件 @
ab675143
...
...
@@ -69,10 +69,10 @@ def start_workers(num_workers):
start_workers
(
3
)
# 定时执行预定系统测试任务1
# schedule.every().day.at("09:00").do(run_task, run_automation_test, report_title="预定系统测试报告", report_url_prefix="http://nat.ubainsyun.com:31134", test_case="预定系统
功能", ding_type="标准版巡检")
schedule
.
every
()
.
day
.
at
(
"19:04"
)
.
do
(
run_task
,
run_automation_test
,
report_title
=
"预定系统测试报告"
,
report_url_prefix
=
"http://nat.ubainsyun.com:31133"
,
test_case
=
"登录
功能"
,
ding_type
=
"标准版巡检"
)
# 定时执行展厅巡检任务
schedule
.
every
()
.
day
.
at
(
"07:
50
"
)
.
do
(
run_task
,
run_automation_test
,
report_title
=
"展厅巡检测试报告"
,
report_url_prefix
=
"http://nat.ubainsyun.com:31133"
,
test_case
=
"展厅巡检"
,
ding_type
=
"展厅巡检"
)
schedule
.
every
()
.
day
.
at
(
"07:
45
"
)
.
do
(
run_task
,
run_automation_test
,
report_title
=
"展厅巡检测试报告"
,
report_url_prefix
=
"http://nat.ubainsyun.com:31133"
,
test_case
=
"展厅巡检"
,
ding_type
=
"展厅巡检"
)
try
:
# 无限循环,持续检查并执行计划任务
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论