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

优化封装好的SELENIUM_LOG_SCREEN函数,增加三个参数用来指定截屏文件存放路径以及截屏文件名称。

上级 b9b1f917
......@@ -234,7 +234,7 @@ def send_keyboard(element_locator, wd):
# 如果元素不可交互,打印不可交互错误消息。
print(f"ElementNotInteractableException: Element {element_locator} is not interactable.")
def get_notify_text(wd):
def get_notify_text(wd,name):
"""
获取通知文本信息。
......@@ -253,7 +253,7 @@ def get_notify_text(wd):
EC.presence_of_element_located((By.XPATH, "//p[@class='el-message__content']"))
).text
# 屏幕截图
SELENIUM_LOG_SCREEN(wd)
SELENIUM_LOG_SCREEN(wd,"50%","User_Manage","User_Add",f"{name}_查看提示信息")
return notify_text
except Exception as e:
# 记录异常信息
......@@ -318,6 +318,28 @@ def read_csv_data(csv_file_path):
# 返回包含所有测试用例数据的列表
return ddt_cases
import os
def delete_images_in_directory(directory):
# 指定要删除的图片文件扩展名
image_extensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff']
# 遍历目录中的所有文件
for filename in os.listdir(directory):
# 获取文件的完整路径
file_path = os.path.join(directory, filename)
# 检查文件是否为图片文件
if any(filename.lower().endswith(ext) for ext in image_extensions):
try:
# 删除文件
os.remove(file_path)
print(f"已删除文件: {file_path}")
except Exception as e:
print(f"删除文件 {file_path} 时出错: {e}")
def browser_quit():
"""
退出浏览器并释放资源。
......
......@@ -36,4 +36,6 @@
- 调试安卓信息MQTT上报没有成功的问题。问题已解决。
10. 2024-11-07
- 补充MQTT模块的README文档。
- 补充脚本执行的命令注释。
\ No newline at end of file
- 补充脚本执行的命令注释。
11. 2024-11-08
- 优化封装好的SELENIUM_LOG_SCREEN函数,增加三个参数用来指定截屏文件存放路径以及截屏文件名称。
\ No newline at end of file
......@@ -46,7 +46,7 @@ class Delete_User_000x:
safe_click((By.XPATH, "//i[@class='el-icon-delete']"), wd)
#屏幕截图
sleep(1)
SELENIUM_LOG_SCREEN(wd)
SELENIUM_LOG_SCREEN(wd,"50%","User_Manage","User_Delete",f"{name}_点击删除")
if expected == "删除成功":
STEP(3, "点击确认按钮")
......@@ -73,4 +73,4 @@ class Delete_User_000x:
CHECK_POINT("检查删除结果", check_text == "暂无数据")
sleep(2)
#屏幕截图
SELENIUM_LOG_SCREEN(wd)
\ No newline at end of file
SELENIUM_LOG_SCREEN(wd,"50%","User_Manage","User_Delete",f"{name}_查看删除结果")
\ No newline at end of file
......@@ -74,13 +74,13 @@ class Add_User_00x:
sleep(2)
#屏幕截图
SELENIUM_LOG_SCREEN(wd)
SELENIUM_LOG_SCREEN(wd,"50%","User_Manage","User_Add",f"{name}_用户信息填入")
STEP(3, "点击【确定】按钮")
#点击确定按钮
safe_click((By.XPATH, "//div[@aria-label='添加用户']//span[contains(text(),'确定')]"), wd)
sleep(2)
notify_text = get_notify_text(wd)
notify_text = get_notify_text(wd,name)
#输出提示信息
INFO(f"Alert text: {notify_text}")
......
......@@ -51,7 +51,7 @@ class Query_User_000x:
# INFO输出获取的文本
INFO(f"检查搜索结果:{check_text}")
# 截屏显示
SELENIUM_LOG_SCREEN(wd)
SELENIUM_LOG_SCREEN(wd,"50%","User_Manage","User_Query",f"{name}_检查搜索结果")
CHECK_POINT("检查搜索结果", check_text == query_text)
elif query_type == 'username':
......@@ -60,7 +60,7 @@ class Query_User_000x:
# INFO输出获取的文本
INFO(f"检查搜索结果:{check_text}")
# 截屏显示
SELENIUM_LOG_SCREEN(wd)
SELENIUM_LOG_SCREEN(wd, "50%", "User_Manage", "User_Query", f"{name}_检查搜索结果")
CHECK_POINT("检查搜索结果", check_text == query_text)
elif query_type == 'departname':
......@@ -69,7 +69,7 @@ class Query_User_000x:
# INFO输出获取的文本
INFO(f"检查搜索结果:{check_text}")
# 截屏显示
SELENIUM_LOG_SCREEN(wd)
SELENIUM_LOG_SCREEN(wd, "50%", "User_Manage", "User_Query", f"{name}_检查搜索结果")
CHECK_POINT("检查搜索结果", query_text in check_text)
elif query_type == 'vague_account':
......@@ -78,7 +78,7 @@ class Query_User_000x:
# INFO输出获取的文本
INFO(f"检查搜索结果:{check_text}")
# 截屏显示
SELENIUM_LOG_SCREEN(wd)
SELENIUM_LOG_SCREEN(wd, "50%", "User_Manage", "User_Query", f"{name}_检查搜索结果")
CHECK_POINT("检查搜索结果", query_text in check_text)
elif query_type == 'vague_username':
......@@ -87,5 +87,5 @@ class Query_User_000x:
# INFO输出获取的文本
INFO(f"检查搜索结果:{check_text}")
# 截屏显示
SELENIUM_LOG_SCREEN(wd)
SELENIUM_LOG_SCREEN(wd, "50%", "User_Manage", "User_Query", f"{name}_检查搜索结果")
CHECK_POINT("检查搜索结果", query_text in check_text)
\ No newline at end of file
=== [ 收集测试用例 ] ===
== cases\__st__.py
== cases\用户管理\__st__.py
== cases\用户管理\主流程.py
** no cases in this file , skip it.
== cases\用户管理\用户删除.py
CSV文件已读取
** no cases in this file , skip it.
== cases\用户管理\用户新增.py
CSV文件已读取
== cases\用户管理\用户查询.py
CSV文件已读取
** no cases in this file , skip it.
== cases\登录模块\账号密码登录测试.py
** no cases in this file , skip it.
== cases\设备管理\安卓信息上报.py
** no cases in this file, skip it.
== cases\设备管理\毫米波雷达上报.py
** no cases in this file, skip it.
=== [ 执行测试用例 ] ===
预备执行用例数量 : 1
========= 测试开始 : 20241107_194325 =========
>>> cases\
[ suite setup ] cases\
-- 第 1 步 -- 初始化浏览器
'----------' 正在初始化浏览器 '----------'
-- 第 2 步 -- 处理SSL认证
'----------' 正在处理SSL证书警告 '----------'
'----------' SSL证书警告处理完成 '----------'
>>> cases\用户管理\
[ suite setup ] cases\用户管理\
输入用户名:admin@ZDH
输入密码:Ubains@4321
输入验证码:csba
点击登录按钮
进入后台
打开账号管理下拉菜单
进入用户管理模块
>>> cases\用户管理\用户新增.py
* 用户新增_001 - 2024-11-07 19:43:30
[ case execution steps ]
-- 第 1 步 -- 点击【新增】按钮
-- 第 2 步 -- 输入账号:,用户名:admin,密码:Ubains@54321,确认密码: Ubains@54321,手机号:13724387311,邮箱:1064963501@qq.com
ABORT Message: target frame detached
(failed to check if window was closed: disconnected: Unable to receive message from renderer)
(Session info: chrome=130.0.6723.93)
Stacktrace:
GetHandleVerifier [0x00007FF60DA0FD55+29557]
(No symbol) [0x00007FF60D9821F0]
(No symbol) [0x00007FF60D83B519]
(No symbol) [0x00007FF60D823E6B]
(No symbol) [0x00007FF60D821D52]
(No symbol) [0x00007FF60D8225AF]
(No symbol) [0x00007FF60D8310CE]
(No symbol) [0x00007FF60D849F64]
(No symbol) [0x00007FF60D8D89C9]
(No symbol) [0x00007FF60D8B72A3]
(No symbol) [0x00007FF60D8812DF]
(No symbol) [0x00007FF60D882451]
GetHandleVerifier [0x00007FF60DD3DC4D+3363437]
GetHandleVerifier [0x00007FF60DD89AD7+3674359]
GetHandleVerifier [0x00007FF60DD7EA7B+3629211]
GetHandleVerifier [0x00007FF60DACFC16+815670]
(No symbol) [0x00007FF60D98D69F]
(No symbol) [0x00007FF60D989264]
(No symbol) [0x00007FF60D989400]
(No symbol) [0x00007FF60D9781AF]
BaseThreadInitThunk [0x00007FFD832E257D+29]
RtlUserThreadStart [0x00007FFD83FCAF08+40]
Traceback:
File "D:\GithubData\自动化脚本-4\ubains-module-test\预定系统\cases\用户管理\用户新增.py", line 56, in teststeps
safe_send_keys((By.XPATH, "//input[@placeholder='11位及以上的大小写字母和数字且连续3位及以上不重复和不连续组合']"), password, wd)
File "D:\GithubData\自动化脚本-4\ubains-module-test\预定系统\Base\base.py", line 139, in safe_send_keys
element.send_keys(value) # 向元素发送指定的键值
File "C:\Users\29194\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webelement.py", line 231, in send_keys
self._execute(
File "C:\Users\29194\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webelement.py", line 395, in _execute
return self._parent.execute(command, params)
File "C:\Users\29194\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 380, in execute
self.error_handler.check_response(response)
File "C:\Users\29194\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: target frame detached
(failed to check if window was closed: disconnected: Unable to receive message from renderer)
(Session info: chrome=130.0.6723.93)
Stacktrace:
GetHandleVerifier [0x00007FF60DA0FD55+29557]
(No symbol) [0x00007FF60D9821F0]
(No symbol) [0x00007FF60D83B519]
(No symbol) [0x00007FF60D823E6B]
(No symbol) [0x00007FF60D821D52]
(No symbol) [0x00007FF60D8225AF]
(No symbol) [0x00007FF60D8310CE]
(No symbol) [0x00007FF60D849F64]
(No symbol) [0x00007FF60D8D89C9]
(No symbol) [0x00007FF60D8B72A3]
(No symbol) [0x00007FF60D8812DF]
(No symbol) [0x00007FF60D882451]
GetHandleVerifier [0x00007FF60DD3DC4D+3363437]
GetHandleVerifier [0x00007FF60DD89AD7+3674359]
GetHandleVerifier [0x00007FF60DD7EA7B+3629211]
GetHandleVerifier [0x00007FF60DACFC16+815670]
(No symbol) [0x00007FF60D98D69F]
(No symbol) [0x00007FF60D989264]
(No symbol) [0x00007FF60D989400]
(No symbol) [0x00007FF60D9781AF]
BaseThreadInitThunk [0x00007FFD832E257D+29]
RtlUserThreadStart [0x00007FFD83FCAF08+40]
[ suite teardown ] cases\
清除浏览器
=== [ 收集测试用例 ] ===
== cases\__st__.py
== cases\用户管理\__st__.py
== cases\用户管理\主流程.py
** no cases in this file , skip it.
== cases\用户管理\用户删除.py
CSV文件已读取
** no cases in this file , skip it.
== cases\用户管理\用户新增.py
CSV文件已读取
** no cases in this file , skip it.
== cases\用户管理\用户查询.py
CSV文件已读取
** no cases in this file , skip it.
== cases\登录模块\账号密码登录测试.py
** no cases in this file , skip it.
== cases\设备管理\安卓信息上报.py
** no cases in this file, skip it.
== cases\设备管理\毫米波雷达上报.py
** no cases in this file, skip it.
=== [ 执行测试用例 ] ===
!! 没有可以执行的测试用例
=== [ 收集测试用例 ] ===
== cases\__st__.py
== cases\用户管理\__st__.py
== cases\用户管理\主流程.py
== cases\用户管理\用户删除.py
CSV文件已读取
** no cases in this file , skip it.
== cases\用户管理\用户新增.py
CSV文件已读取
** no cases in this file , skip it.
== cases\用户管理\用户查询.py
CSV文件已读取
** no cases in this file , skip it.
== cases\登录模块\账号密码登录测试.py
** no cases in this file , skip it.
== cases\设备管理\安卓信息上报.py
** no cases in this file, skip it.
== cases\设备管理\毫米波雷达上报.py
** no cases in this file, skip it.
=== [ 执行测试用例 ] ===
预备执行用例数量 : 1
========= 测试开始 : 20241106_170124 =========
>>> cases\
[ suite setup ] cases\
-- 第 1 步 -- 初始化浏览器
'----------' 正在初始化浏览器 '----------'
-- 第 2 步 -- 处理SSL认证
'----------' 正在处理SSL证书警告 '----------'
'----------' SSL证书警告处理完成 '----------'
>>> cases\用户管理\
[ suite setup ] cases\用户管理\
输入用户名:admin@ZDH
输入密码:Ubains@4321
输入验证码:csba
点击登录按钮
进入后台
打开账号管理下拉菜单
进入用户管理模块
>>> cases\用户管理\主流程.py
* Main_User_Manage_0001 - 2024-11-06 17:01:28
[ case execution steps ]
-- 第 1 步 -- 点击【新增】按钮
-- 第 2 步 -- 输入账号:admin@Test,用户名:admin@Test,密码:Ubains@54321,确认密码: Ubains@54321,手机号:17319004611,邮箱:2919407801@qq.com
picture imgs/20241106170133580940.png
-- 第 3 步 -- 点击【确定】按钮
picture imgs/20241106170135762508.png
** 检查点 ** 弹出提示 ----> 通过
-- 第 4 步 -- 管理员退出登录
-- 第 5 步 -- admin@Test用户登录系统
登录账号:admin@Test,登录密码:Ubains@54321,登录验证码:'csba'
picture imgs/20241106170138327435.png
首次登录提示:首次登录,请修改密码
** 检查点 ** 弹出提示 ----> 通过
-- 第 6 步 -- admin@Test修改用户密码
修改密码为:Ubains@4321
picture imgs/20241106170142183138.png
首次登录修改密码提示:修改成功,请重新登录
** 检查点 ** 弹出提示 ----> 通过
-- 第 7 步 -- admin@Test用户重新登录系统
登录账号:admin@Test,登录密码:Ubains@4321,登录验证码:'csba'
登录系统提示:欢迎 自动化测试公司
** 检查点 ** 登录成功校验 ----> 通过
picture imgs/20241106170144975967.png
PASS
[ suite teardown ] cases\
清除浏览器
========= 测试结束 : 20241106_170147 =========
耗时 : 22.914 秒
预备执行用例数量 : 1
实际执行用例数量 : 1
通过 : 1
失败 : 0
异常 : 0
套件初始化失败 : 0
套件清除 失败 : 0
用例初始化失败 : 0
用例清除 失败 : 0
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论