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

调整封装get_reportfile_send_dingding函数用来获取测试报告文件并拼接IP地址,并发送钉钉群消息。优化定时任务run_automat...

调整封装get_reportfile_send_dingding函数用来获取测试报告文件并拼接IP地址,并发送钉钉群消息。优化定时任务run_automation_test函数的调用处理,并增加对于的日志输出。补充定时任务执行的注解。调整元素定位的显示等待时间,避免因服务器的网络波动导致元素获取异常。
上级 88762ce2
此差异已折叠。
...@@ -72,3 +72,9 @@ ...@@ -72,3 +72,9 @@
- 调试定时任务的问题,还需再进一步调试。 - 调试定时任务的问题,还需再进一步调试。
- 补充运维集控的MQTT底层方法与消息体构建。 - 补充运维集控的MQTT底层方法与消息体构建。
- 调试定时任务执行后钉钉消息没有发送的问题。将定时任务与测试报告文件获取封装成函数进行调用,方便后续维护管理。目前调试发现定时任务执行别的脚本时会出现异常问题,需要进一步排查。 - 调试定时任务执行后钉钉消息没有发送的问题。将定时任务与测试报告文件获取封装成函数进行调用,方便后续维护管理。目前调试发现定时任务执行别的脚本时会出现异常问题,需要进一步排查。
21. 2024-11-27
- 调试定时任务执行完成后没有发送钉钉群消息的问题,并优化SSL处理方式。
22. 2024-11-28
- 封装get_reportfile_send_dingding函数用来获取测试报告文件并拼接IP地址,并发送钉钉群消息。优化定时任务run_automation_test函数的调用处理,并增加对于的日志输出。
- 补充定时任务执行的注解。
- 调整元素定位的显示等待时间,避免因服务器的网络波动导致元素获取异常。
\ No newline at end of file
...@@ -18,8 +18,8 @@ except ModuleNotFoundError as e: ...@@ -18,8 +18,8 @@ except ModuleNotFoundError as e:
def suite_setup(): def suite_setup():
STEP(1, "初始化浏览器") STEP(1, "初始化浏览器")
browser_init() browser_init()
STEP(2, "处理SSL认证") # STEP(2, "处理SSL认证")
handle_ssl_warning() # handle_ssl_warning()
def suite_teardown(): def suite_teardown():
browser_quit() browser_quit()
\ No newline at end of file
from time import sleep from time import sleep
from hytest import * from 预定系统.cases.账号管理.用户管理.__st__ import *
# 获取当前脚本的绝对路径 # 获取当前脚本的绝对路径
current_dir = os.path.dirname(os.path.abspath(__file__)) current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建预定系统的绝对路径 # 构建预定系统的绝对路径
...@@ -8,25 +9,42 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -8,25 +9,42 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(预定系统_path) sys.path.append(预定系统_path)
# 导入模块 # 导入模块
from 预定系统.Base.base import * from 预定系统.Base.base import *
account = 'admin@Test' # 获取当前脚本所在的目录
username = 'admin@Test' current_dir = os.path.dirname(os.path.abspath(__file__))
password = 'Ubains@54321'
new_password = 'Ubains@4321' # 构建CSV文件的绝对路径
phone = '17319004611' csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户管理主流程.csv')
email = '2919407801@qq.com'
# 配置日志记录器,仅输出到控制台
class Main_User_Manage_0001: logging.basicConfig(
tags = ['用户管理功能'] level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler()
]
)
class Main_User_Manage_000x:
# tags = ['用户管理功能']
""" """
执行指令: 执行指令:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 用户主流程测试报告 --test Main_User_Manage_0001 2.hytest --report_title 用户主流程测试报告 --report_url_prefix http://192.168.1.166 --test 用户管理主流程_001
""" """
def teststeps(self): def teststeps(self):
"""
执行测试步骤以用户管理的主流程功能。
本函数根据参数添加用户,并使用新增的用户进行登录的提示信息是否与预期相符。
"""
login_url = 'https://192.168.5.218/#/login/logindf'
# 初始化通知文本为空字符串 # 初始化通知文本为空字符串
notify_text = "" notify_text = ""
# 从全局存储中获取webdriver实例 # 从全局存储中获取webdriver实例
wd = GSTORE['wd'] wd = GSTORE['wd']
# 从self.para中解构出用户名、密码、验证码和检查文本
name = self.name
account, username, password, new_password, phone, email = self.para
STEP(1, "点击【新增】按钮") STEP(1, "点击【新增】按钮")
safe_click((By.XPATH, "//span[contains(text(),'添 加')]"), wd) safe_click((By.XPATH, "//span[contains(text(),'添 加')]"), wd)
...@@ -105,12 +123,28 @@ class Main_User_Manage_0001: ...@@ -105,12 +123,28 @@ class Main_User_Manage_0001:
safe_send_keys((By.XPATH, "//input[@placeholder='请输入账号或手机号或邮箱号']"),account,wd) safe_send_keys((By.XPATH, "//input[@placeholder='请输入账号或手机号或邮箱号']"),account,wd)
safe_send_keys((By.XPATH, "//input[@placeholder='请输入密码']"),new_password,wd) safe_send_keys((By.XPATH, "//input[@placeholder='请输入密码']"),new_password,wd)
safe_send_keys((By.XPATH, "//input[@placeholder='请输入图形验证码']"),'csba',wd) safe_send_keys((By.XPATH, "//input[@placeholder='请输入图形验证码']"),'csba',wd)
INFO("点击登录按钮")
sleep(1)
safe_click((By.XPATH, "//input[@value='登 录']"),wd) safe_click((By.XPATH, "//input[@value='登 录']"),wd)
sleep(2) sleep(2)
INFO("获取登录信息")
notify_text = elment_get_text((By.XPATH, "//span[contains(text(),'欢迎 自动化测试公司')]"),wd) notify_text = elment_get_text((By.XPATH, "//span[contains(text(),'欢迎 自动化测试公司')]"),wd)
# 检查点:验证提示信息是否与预期相符 # 检查点:验证提示信息是否与预期相符
INFO(f"登录系统提示:{notify_text}") INFO(f"登录系统提示:{notify_text}")
CHECK_POINT('登录成功校验', notify_text == "欢迎 自动化测试公司") CHECK_POINT('登录成功校验', notify_text == "欢迎 自动化测试公司")
SELENIUM_LOG_SCREEN(wd,"50%","User_Manage","User_Main","用户管理主流程-用户登录") SELENIUM_LOG_SCREEN(wd,"50%","User_Manage","User_Main","用户管理主流程-用户登录")
# 清除浏览器,再重新打开浏览器
wd.get(login_url)
# 最大化浏览器窗口
wd.maximize_window()
admin_login()
enter_the_backend()
INFO("打开账号管理下拉菜单")
safe_click((By.XPATH, "//span[@class='aside_menu menu_account']"), wd)
INFO("进入用户管理模块")
safe_click((By.XPATH, "//li[contains(text(),'用户管理')]"), wd)
\ No newline at end of file
...@@ -13,6 +13,7 @@ except ModuleNotFoundError as e: ...@@ -13,6 +13,7 @@ except ModuleNotFoundError as e:
print(f"ModuleNotFoundError: {e}") print(f"ModuleNotFoundError: {e}")
print("尝试使用绝对路径导入") print("尝试使用绝对路径导入")
from 预定系统.Base.base import * from 预定系统.Base.base import *
from 预定系统.cases.账号管理.用户管理.__st__ import *
# 获取当前脚本所在的目录 # 获取当前脚本所在的目录
current_dir = os.path.dirname(os.path.abspath(__file__)) current_dir = os.path.dirname(os.path.abspath(__file__))
...@@ -20,6 +21,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -20,6 +21,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建CSV文件的绝对路径 # 构建CSV文件的绝对路径
csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户修改密码.csv') csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户修改密码.csv')
# 配置日志记录器,仅输出到控制台
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler()
]
)
class User_Chanage_Pwd_000x: class User_Chanage_Pwd_000x:
tags = ['用户管理功能'] tags = ['用户管理功能']
""" """
...@@ -34,6 +45,7 @@ class User_Chanage_Pwd_000x: ...@@ -34,6 +45,7 @@ class User_Chanage_Pwd_000x:
执行测试步骤以用户新增功能。 执行测试步骤以用户新增功能。
本函数根据参数输入账号、用户名、密码、确认密码、部门、性别、手机号和邮箱,并检查新增后的提示信息是否与预期相符。 本函数根据参数输入账号、用户名、密码、确认密码、部门、性别、手机号和邮箱,并检查新增后的提示信息是否与预期相符。
""" """
login_url = 'https://192.168.5.218/#/login/logindf'
# 初始化通知文本为空字符串 # 初始化通知文本为空字符串
notify_text = "" notify_text = ""
# 从全局存储中获取webdriver实例 # 从全局存储中获取webdriver实例
...@@ -73,7 +85,7 @@ class User_Chanage_Pwd_000x: ...@@ -73,7 +85,7 @@ class User_Chanage_Pwd_000x:
STEP(4, '点击确定按钮') STEP(4, '点击确定按钮')
INFO('点击确定按钮') INFO('点击确定按钮')
safe_click((By.XPATH, safe_click((By.XPATH,
"//body/div[@class='el-dialog__wrapper']/div[@aria-label='修改密码']/div[@class='el-dialog__footer']/span[@class='dialog-footer']/button[@type='button']/span[1]"), "//body/div[@class='el-dialog__wrapper']/div[@aria-label='修改密码']/div[@class='el-dialog__footer']/span[@class='dialog-footer']/button[1]"),
wd) wd)
sleep(2) sleep(2)
STEP(5, '检查提示信息') STEP(5, '检查提示信息')
...@@ -102,3 +114,17 @@ class User_Chanage_Pwd_000x: ...@@ -102,3 +114,17 @@ class User_Chanage_Pwd_000x:
f'{name}检查提示信息') f'{name}检查提示信息')
INFO(f'校验修改密码提示信息:{notify_text}') INFO(f'校验修改密码提示信息:{notify_text}')
CHECK_POINT('校验修改密码提示信息', notify_text == check_text) CHECK_POINT('校验修改密码提示信息', notify_text == check_text)
if name == '用户修改密码_022':
# 清除浏览器,再重新打开浏览器
wd.get(login_url)
# 最大化浏览器窗口
wd.maximize_window()
admin_login()
enter_the_backend()
INFO("打开账号管理下拉菜单")
safe_click((By.XPATH, "//span[@class='aside_menu menu_account']"), wd)
INFO("进入用户管理模块")
safe_click((By.XPATH, "//li[contains(text(),'用户管理')]"), wd)
\ No newline at end of file
...@@ -13,6 +13,7 @@ except ModuleNotFoundError as e: ...@@ -13,6 +13,7 @@ except ModuleNotFoundError as e:
print(f"ModuleNotFoundError: {e}") print(f"ModuleNotFoundError: {e}")
print("尝试使用绝对路径导入") print("尝试使用绝对路径导入")
from 预定系统.Base.base import * from 预定系统.Base.base import *
from 预定系统.cases.账号管理.用户管理.__st__ import *
# 获取当前脚本所在的目录 # 获取当前脚本所在的目录
current_dir = os.path.dirname(os.path.abspath(__file__)) current_dir = os.path.dirname(os.path.abspath(__file__))
...@@ -20,6 +21,15 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -20,6 +21,15 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建CSV文件的绝对路径 # 构建CSV文件的绝对路径
csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户新增.csv') csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户新增.csv')
# 配置日志记录器,仅输出到控制台
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler()
]
)
class Add_User_000x: class Add_User_000x:
tags = ['用户管理功能'] tags = ['用户管理功能']
""" """
...@@ -34,6 +44,7 @@ class Add_User_000x: ...@@ -34,6 +44,7 @@ class Add_User_000x:
执行测试步骤以用户新增功能。 执行测试步骤以用户新增功能。
本函数根据参数输入账号、用户名、密码、确认密码、部门、性别、手机号和邮箱,并检查新增后的提示信息是否与预期相符。 本函数根据参数输入账号、用户名、密码、确认密码、部门、性别、手机号和邮箱,并检查新增后的提示信息是否与预期相符。
""" """
login_url = 'https://192.168.5.218/#/login/logindf'
# 初始化通知文本为空字符串 # 初始化通知文本为空字符串
notify_text = "" notify_text = ""
# 从全局存储中获取webdriver实例 # 从全局存储中获取webdriver实例
...@@ -95,3 +106,17 @@ class Add_User_000x: ...@@ -95,3 +106,17 @@ class Add_User_000x:
if check_text == '添加成功': if check_text == '添加成功':
safe_click((By.XPATH, "//span[contains(text(),'添 加')]"), wd) safe_click((By.XPATH, "//span[contains(text(),'添 加')]"), wd)
sleep(1) sleep(1)
if name == '用户新增_048':
# 清除浏览器,再重新打开浏览器
wd.get(login_url)
# 最大化浏览器窗口
wd.maximize_window()
admin_login()
enter_the_backend()
INFO("打开账号管理下拉菜单")
safe_click((By.XPATH, "//span[@class='aside_menu menu_account']"), wd)
INFO("进入用户管理模块")
safe_click((By.XPATH, "//li[contains(text(),'用户管理')]"), wd)
\ No newline at end of file
import csv import csv
from time import sleep from time import sleep
from hytest import * from hytest import *
# 获取当前脚本的绝对路径 # 获取当前脚本的绝对路径
current_dir = os.path.dirname(os.path.abspath(__file__)) current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建预定系统的绝对路径 # 构建预定系统的绝对路径
...@@ -10,6 +9,7 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -10,6 +9,7 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(预定系统_path) sys.path.append(预定系统_path)
# 导入模块 # 导入模块
from 预定系统.Base.base import * from 预定系统.Base.base import *
from 预定系统.cases.账号管理.用户管理.__st__ import *
# 获取当前脚本所在的目录 # 获取当前脚本所在的目录
current_dir = os.path.dirname(os.path.abspath(__file__)) current_dir = os.path.dirname(os.path.abspath(__file__))
...@@ -17,6 +17,15 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -17,6 +17,15 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建CSV文件的绝对路径 # 构建CSV文件的绝对路径
csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户查询.csv') csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户查询.csv')
# 配置日志记录器,仅输出到控制台
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler()
]
)
class Query_User_000x: class Query_User_000x:
tags = ['用户管理功能'] tags = ['用户管理功能']
""" """
...@@ -33,6 +42,7 @@ class Query_User_000x: ...@@ -33,6 +42,7 @@ class Query_User_000x:
query_text:查询文本 query_text:查询文本
query_type:查询类型 query_type:查询类型
""" """
login_url = 'https://192.168.5.218/#/login/logindf'
# 从全局存储中获取webdriver实例 # 从全局存储中获取webdriver实例
wd = GSTORE['wd'] wd = GSTORE['wd']
# 从self.para中解构出查询文本以及查询类型 # 从self.para中解构出查询文本以及查询类型
...@@ -94,3 +104,17 @@ class Query_User_000x: ...@@ -94,3 +104,17 @@ class Query_User_000x:
# 截屏显示 # 截屏显示
SELENIUM_LOG_SCREEN(wd, "50%", "User_Manage", "User_Query", f"{name}_检查搜索结果") SELENIUM_LOG_SCREEN(wd, "50%", "User_Manage", "User_Query", f"{name}_检查搜索结果")
CHECK_POINT("检查搜索结果", query_text in check_text) CHECK_POINT("检查搜索结果", query_text in check_text)
if name == '用户查询_044':
# 清除浏览器,再重新打开浏览器
wd.get(login_url)
# 最大化浏览器窗口
wd.maximize_window()
admin_login()
enter_the_backend()
INFO("打开账号管理下拉菜单")
safe_click((By.XPATH, "//span[@class='aside_menu menu_account']"), wd)
INFO("进入用户管理模块")
safe_click((By.XPATH, "//li[contains(text(),'用户管理')]"), wd)
\ No newline at end of file
...@@ -9,6 +9,7 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -9,6 +9,7 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(预定系统_path) sys.path.append(预定系统_path)
# 导入模块 # 导入模块
from 预定系统.Base.base import * from 预定系统.Base.base import *
from 预定系统.cases.账号管理.用户管理.__st__ import *
# 获取当前脚本所在的目录 # 获取当前脚本所在的目录
current_dir = os.path.dirname(os.path.abspath(__file__)) current_dir = os.path.dirname(os.path.abspath(__file__))
...@@ -16,6 +17,15 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -16,6 +17,15 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建CSV文件的绝对路径 # 构建CSV文件的绝对路径
csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户删除.csv') csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户删除.csv')
# 配置日志记录器,仅输出到控制台
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler()
]
)
class Delete_User_000x: class Delete_User_000x:
tags = ['用户管理功能'] tags = ['用户管理功能']
""" """
...@@ -30,6 +40,7 @@ class Delete_User_000x: ...@@ -30,6 +40,7 @@ class Delete_User_000x:
执行测试步骤以用户删除功能。 执行测试步骤以用户删除功能。
本函数根据参数输入账号,并检查删除后的数据是否减少。 本函数根据参数输入账号,并检查删除后的数据是否减少。
""" """
login_url = 'https://192.168.5.218/#/login/logindf'
notify_text = "" notify_text = ""
# 从全局存储中获取webdriver实例 # 从全局存储中获取webdriver实例
wd = GSTORE['wd'] wd = GSTORE['wd']
...@@ -79,3 +90,17 @@ class Delete_User_000x: ...@@ -79,3 +90,17 @@ class Delete_User_000x:
sleep(2) sleep(2)
#屏幕截图 #屏幕截图
SELENIUM_LOG_SCREEN(wd,"50%","User_Manage","User_Delete",f"{name}_查看删除结果") SELENIUM_LOG_SCREEN(wd,"50%","User_Manage","User_Delete",f"{name}_查看删除结果")
if name == "用户删除_012":
# 清除浏览器,再重新打开浏览器
wd.get(login_url)
# 最大化浏览器窗口
wd.maximize_window()
admin_login()
enter_the_backend()
INFO("打开账号管理下拉菜单")
safe_click((By.XPATH, "//span[@class='aside_menu menu_account']"), wd)
INFO("进入用户管理模块")
safe_click((By.XPATH, "//li[contains(text(),'用户管理')]"), wd)
\ No newline at end of file
...@@ -13,6 +13,7 @@ except ModuleNotFoundError as e: ...@@ -13,6 +13,7 @@ except ModuleNotFoundError as e:
print(f"ModuleNotFoundError: {e}") print(f"ModuleNotFoundError: {e}")
print("尝试使用绝对路径导入") print("尝试使用绝对路径导入")
from 预定系统.Base.base import * from 预定系统.Base.base import *
from 预定系统.cases.账号管理.用户管理.__st__ import *
# 获取当前脚本所在的目录 # 获取当前脚本所在的目录
current_dir = os.path.dirname(os.path.abspath(__file__)) current_dir = os.path.dirname(os.path.abspath(__file__))
...@@ -20,6 +21,15 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -20,6 +21,15 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建CSV文件的绝对路径 # 构建CSV文件的绝对路径
csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户状态设置.csv') csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户状态设置.csv')
# 配置日志记录器,仅输出到控制台
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler()
]
)
class User_Status_000x: class User_Status_000x:
tags = ['用户管理功能'] tags = ['用户管理功能']
""" """
...@@ -31,9 +41,10 @@ class User_Status_000x: ...@@ -31,9 +41,10 @@ class User_Status_000x:
def teststeps(self): def teststeps(self):
""" """
执行测试步骤以用户新增功能。 执行测试步骤以用户状态设置功能。
本函数根据参数输入账号、用户名、密码、确认密码、部门、性别、手机号和邮箱,并检查新增后的提示信息是否与预期相符。 本函数根据参数选择用户进行【启用】与【停用】操作,并检查停用、启用后登录系统的提示信息是否与预期相符。
""" """
login_url = 'https://192.168.5.218/#/login/logindf'
# 初始化通知文本为空字符串 # 初始化通知文本为空字符串
notify_text = "" notify_text = ""
# 从全局存储中获取webdriver实例 # 从全局存储中获取webdriver实例
...@@ -114,7 +125,23 @@ class User_Status_000x: ...@@ -114,7 +125,23 @@ class User_Status_000x:
safe_send_keys((By.XPATH, "//input[@placeholder='请输入密码']"), 'Ubains@4321', wd) safe_send_keys((By.XPATH, "//input[@placeholder='请输入密码']"), 'Ubains@4321', wd)
safe_send_keys((By.XPATH, "//input[@placeholder='请输入图形验证码']"), 'csba', wd) safe_send_keys((By.XPATH, "//input[@placeholder='请输入图形验证码']"), 'csba', wd)
safe_click((By.XPATH, "//input[@value='登 录']"), wd) safe_click((By.XPATH, "//input[@value='登 录']"), wd)
sleep(2) sleep(4)
notify_text = elment_get_text((By.XPATH, "//span[contains(text(),'欢迎 自动化测试公司')]"), wd) notify_text = elment_get_text((By.XPATH, f"//span[normalize-space()='{username}']"), wd)
INFO(f'校验登录提示信息:{notify_text}') INFO(f'校验登录提示信息:{notify_text}')
CHECK_POINT('校验登录提示信息', notify_text == '欢迎 自动化测试公司') CHECK_POINT('校验登录提示信息', username in notify_text)
\ No newline at end of file sleep(2)
if name == '用户状态设置_004':
# 清除浏览器,再重新打开浏览器
wd.get(login_url)
# 最大化浏览器窗口
wd.maximize_window()
admin_login()
enter_the_backend()
wd.refresh()
INFO("打开账号管理下拉菜单")
safe_click((By.XPATH, "//span[@class='aside_menu menu_account']"), wd)
INFO("进入用户管理模块")
safe_click((By.XPATH, "//li[contains(text(),'用户管理')]"), wd)
\ No newline at end of file
...@@ -13,6 +13,7 @@ except ModuleNotFoundError as e: ...@@ -13,6 +13,7 @@ except ModuleNotFoundError as e:
print(f"ModuleNotFoundError: {e}") print(f"ModuleNotFoundError: {e}")
print("尝试使用绝对路径导入") print("尝试使用绝对路径导入")
from 预定系统.Base.base import * from 预定系统.Base.base import *
from 预定系统.cases.账号管理.用户管理.__st__ import *
# 获取当前脚本所在的目录 # 获取当前脚本所在的目录
current_dir = os.path.dirname(os.path.abspath(__file__)) current_dir = os.path.dirname(os.path.abspath(__file__))
...@@ -20,6 +21,15 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -20,6 +21,15 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建CSV文件的绝对路径 # 构建CSV文件的绝对路径
csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户编辑.csv') csv_file_path = os.path.join(current_dir, '../../../测试数据/账号管理/用户管理模块/用户编辑.csv')
# 配置日志记录器,仅输出到控制台
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler()
]
)
class User_Edit_000x: class User_Edit_000x:
tags = ['用户管理功能'] tags = ['用户管理功能']
""" """
...@@ -34,6 +44,7 @@ class User_Edit_000x: ...@@ -34,6 +44,7 @@ class User_Edit_000x:
执行测试步骤以用户新增功能。 执行测试步骤以用户新增功能。
本函数根据参数输入账号、用户名、密码、确认密码、部门、性别、手机号和邮箱,并检查新增后的提示信息是否与预期相符。 本函数根据参数输入账号、用户名、密码、确认密码、部门、性别、手机号和邮箱,并检查新增后的提示信息是否与预期相符。
""" """
login_url = 'https://192.168.5.218/#/login/logindf'
# 初始化通知文本为空字符串 # 初始化通知文本为空字符串
notify_text = "" notify_text = ""
# 从全局存储中获取webdriver实例 # 从全局存储中获取webdriver实例
...@@ -55,7 +66,7 @@ class User_Edit_000x: ...@@ -55,7 +66,7 @@ class User_Edit_000x:
notify_text = elment_get_text((By.XPATH, "//span[contains(text(),'编辑用户')]"), wd) notify_text = elment_get_text((By.XPATH, "//span[contains(text(),'编辑用户')]"), wd)
INFO(f'校验编辑界面UI:{notify_text}') INFO(f'校验编辑界面UI:{notify_text}')
CHECK_POINT('校验编辑界面', "编辑用户" in notify_text) CHECK_POINT('校验编辑界面', "编辑用户" in notify_text)
sleep(1) sleep(2)
# 执行输入用户信息的步骤 # 执行输入用户信息的步骤
STEP(2, f'输入用户名:{new_username}') STEP(2, f'输入用户名:{new_username}')
...@@ -64,11 +75,12 @@ class User_Edit_000x: ...@@ -64,11 +75,12 @@ class User_Edit_000x:
safe_send_keys((By.XPATH, "//input[@placeholder='用户名']"), new_username, wd) safe_send_keys((By.XPATH, "//input[@placeholder='用户名']"), new_username, wd)
# 清除下拉框数据 # 清除下拉框数据
if name != '用户编辑_001': # if name != '用户编辑_001':
safe_click((By.XPATH, "//i[@class='el-tag__close el-icon-close']"), wd) safe_click((By.XPATH, "//i[@class='el-tag__close el-icon-close']"), wd)
sleep(2)
# 点击部门下拉框 # 点击部门下拉框
safe_click((By.XPATH, "//div[@class='el-input el-input--suffix']//input[@placeholder='请选择']"), wd) safe_click((By.XPATH, "//div[@class='el-input el-input--suffix']//input[@placeholder='请选择']"), wd)
sleep(2)
# 选择部门 # 选择部门
safe_click((By.XPATH, "/html[1]/body[1]/div[4]/div[1]/div[1]/div[1]/ul[1]/li[1]/label[1]/span[1]/span[1]"), wd) safe_click((By.XPATH, "/html[1]/body[1]/div[4]/div[1]/div[1]/div[1]/ul[1]/li[1]/label[1]/span[1]/span[1]"), wd)
...@@ -86,7 +98,22 @@ class User_Edit_000x: ...@@ -86,7 +98,22 @@ class User_Edit_000x:
safe_click((By.XPATH, "//div[@aria-label='编辑用户']//span[contains(text(),'确定')]"), wd) safe_click((By.XPATH, "//div[@aria-label='编辑用户']//span[contains(text(),'确定')]"), wd)
# 检查操作后的提示信息 # 检查操作后的提示信息
sleep(2)
STEP(4, '检查提示信息') STEP(4, '检查提示信息')
notify_text = get_notify_text(wd, (By.XPATH,"//p[@class='el-message__content']"), 'User_Manage', 'User_Chanage_Pwd', notify_text = get_notify_text(wd, (By.XPATH,"//p[@class='el-message__content']"), 'User_Manage', 'User_Chanage_Pwd',
f'{name}检查提示信息') f'{name}检查提示信息')
CHECK_POINT('校验编辑用户提示信息', notify_text == check_text) CHECK_POINT('校验编辑用户提示信息', notify_text == check_text)
# if name == '用户编辑_018':
# # 清除浏览器,再重新打开浏览器
# wd.get(login_url)
# # 最大化浏览器窗口
# wd.maximize_window()
# admin_login()
# enter_the_backend()
#
# INFO("打开账号管理下拉菜单")
# safe_click((By.XPATH, "//span[@class='aside_menu menu_account']"), wd)
#
# INFO("进入用户管理模块")
# safe_click((By.XPATH, "//li[contains(text(),'用户管理')]"), wd)
\ No newline at end of file
此差异已折叠。
import schedule
from Base.base import * from Base.base import *
# 配置日志记录器,仅输出到控制台
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler()
]
)
"""
执行指令:
打开终端1:
1.cd 预定系统
2.python ./定时执行功能测试.py
打开终端2:
1.python -m http.server 80 --directory reports (可以让同网段下的电脑通过使用测试主机的IP地址+测试报告文件进行访问查看)
"""
# 每天凌晨 0 点执行任务 # 每天凌晨 0 点执行任务
schedule.every().day.at("21:18").do(run_automation_test, report_title="账号密码登录模块_测试报告", report_url_prefix="http://192.168.1.166", test_case="登录_0**") schedule.every().day.at("09:30").do(run_automation_test, report_title="用户管理模块_测试报告", report_url_prefix="http://192.168.1.166", test_case="用户管理功能")
# schedule.every().day.at("21:14").do(run_automation_test, report_title="用户管理模块_主流程_测试报告", report_url_prefix="http://192.168.1.166", test_case="Main_User_Manage_0001")
try: try:
# 无限循环,持续检查并执行计划任务
while True: while True:
schedule.run_pending() schedule.run_pending() # 检查并执行所有待处理的任务
time.sleep(5) time.sleep(1) # 每秒检查一次
except KeyboardInterrupt: except KeyboardInterrupt:
# 捕获用户中断信号 (Ctrl+C)
logging.info("Scheduler interrupted by user.") logging.info("Scheduler interrupted by user.")
except Exception as e: except Exception as e:
# 捕获其他未预期的异常
logging.error(f"Unexpected error: {e}") logging.error(f"Unexpected error: {e}")
#
# if __name__ == "__main__":
# get_reportfile_send_dingding("用户管理模块_测试报告", "http://192.168.1.166")
\ No newline at end of file
...@@ -9,4 +9,5 @@ name,account,expected ...@@ -9,4 +9,5 @@ name,account,expected
用户删除_008,admin@37,删除成功 用户删除_008,admin@37,删除成功
用户删除_009,admin@38,删除成功 用户删除_009,admin@38,删除成功
用户删除_010,admin@44,删除成功 用户删除_010,admin@44,删除成功
用户删除_011,admin@51,删除成功 用户删除_011,admin@48,删除成功
\ No newline at end of file 用户删除_012,admin@51,删除成功
\ No newline at end of file
name,account,username,password,new_password,phone,email
用户管理主流程_001,admin@Test,admin@Test,Ubains@54321,Ubains@4321,17319004611,2919407801@qq.com
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论