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

feat(test): 更新自动化测试配置与功能增强

- 删除冗余的__st__.py初始化文件
- 移除base.py中的硬编码ChromeDriver路径
- 更新ngrok配置文件端口映射设置
- 修改定时任务执行脚本端口号与URL前缀
- 增强功能测试用例支持页面刷新与跳转操作
- 调整HTTP服务器监听端口避免冲突
- 简化预定系统与统一平台测试调度配置
- 移除已废弃的测试用例文件系统功能测试.py
上级 0e5dc020
......@@ -78,10 +78,6 @@ def browser_init(login_type):
# 手动指定ChromeDriver的路径
# chromedriver下载地址:https://googlechromelabs.github.io/chrome-for-testing/
# 自动化运行服务器的chromedriver路径:
# 拯救者电脑
# service = Service(r'C:\Users\29194\AppData\Local\Programs\Python\Python310\Scripts\chromedriver.exe')
# EDY电脑
# service = Service(r'C:\Users\EDY\AppData\Local\Programs\Python\Python310\Scripts\chromedriver.exe')
# 云电脑
# service = Service(r'E:\Python\Scripts\chromedriver.exe')
# 自动化虚拟机
......
......@@ -17,7 +17,7 @@ class NewUnifiedPlatform:
# cd ./新统一平台/
# hytest --tag 新统一平台
tags = ['新统一平台前台首页', '新统一平台']
ddt_cases = read_xlsx_data(xlsx_file_path, case_type="标准版")
ddt_cases = read_xlsx_data(xlsx_file_path,sheet_name="新统一平台跳转", case_type="标准版")
def teststeps(self):
"""
......@@ -101,4 +101,16 @@ class NewUnifiedPlatform:
INFO(f"获取到的文本信息为:{text}")
CHECK_POINT(f"获取到的文本信息为:{text}", expected_result in text)
SELENIUM_LOG_SCREEN(wd, "75")
sleep(2)
\ No newline at end of file
sleep(2)
elif element_type == "refresh":
# 刷新页面
INFO("刷新页面")
wd.refresh()
sleep(5)
elif element_type == "url_jump":
# 跳转页面
INFO(f"跳转页面:{element_value}")
wd.get(element_value)
sleep(5)
\ No newline at end of file
......@@ -105,4 +105,16 @@ class NewUnifiedPlatform:
INFO(f"获取到的文本信息为:{text}")
CHECK_POINT(f"获取到的文本信息为:{text}", expected_result in text)
SELENIUM_LOG_SCREEN(wd, "75")
sleep(2)
\ No newline at end of file
sleep(2)
elif element_type == "refresh":
# 刷新页面
INFO("刷新页面")
wd.refresh()
sleep(5)
elif element_type == "url_jump":
# 跳转页面
INFO(f"跳转页面:{element_value}")
wd.get(element_value)
sleep(5)
\ No newline at end of file
......@@ -3,5 +3,5 @@ trust_host_root_certs: false
tunnels:
nat1:
proto:
tcp: 127.0.0.1:80
remote_port: 31137
tcp: "127.0.0.1:80"
remote_port: 31133
\ No newline at end of file
......@@ -89,7 +89,7 @@ def start_workers(num_workers):
start_workers(3)
# 定时执行新统一平台标准版
schedule.every(2).hours.do(run_task, run_automation_test, report_title="新统一平台测试报告", report_url_prefix="http://nat.ubainsyun.com:31137", test_case="新统一平台", ding_type="标准版巡检")
schedule.every(2).hours.do(run_task, run_automation_test, report_title="新统一平台测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="新统一平台", ding_type="标准版巡检")
try:
# 无限循环,持续检查并执行计划任务
......
import sys
import os
from time import sleep
# 获取当前脚本的绝对路径
current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建统一平台的绝对路径
platform_path = os.path.abspath(os.path.join(current_dir, '..','..','..'))
# 添加路径
sys.path.append(platform_path)
# 导入模块
try:
from 统一平台.base.bases import *
except ModuleNotFoundError as e:
INFO(f"ModuleNotFoundError: {e}")
INFO("尝试使用绝对路径导入")
from 统一平台.base.bases import *
def suite_setup():
STEP(1, "初始化浏览器")
browser_init("新统一平台")
def suite_teardown():
browser_quit()
\ No newline at end of file
import sys
import os
# 获取当前脚本的绝对路径
current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建统一平台的绝对路径
platform_path = os.path.abspath(os.path.join(current_dir, '..','..','..'))
# 添加路径到系统路径中
sys.path.append(platform_path)
# 导入模块
from 统一平台.base.bases import *
# 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', 'data', '新统一平台测试用例.xlsx')
class NewUnifiedPlatform:
#执行指令:
# cd ./统一平台/
# hytest --tag 新统一平台
tags = ['新统一平台']
ddt_cases = read_xlsx_data(xlsx_file_path, case_type="标准版")
def teststeps(self):
"""
执行测试步骤函数,主要用于执行读取的测试用例并进行信息统计模块功能测试操作
"""
# 从全局存储中获取webdriver对象
wd = GSTORE['wd']
name = self.name
# 刷新页面
# wd.refresh()
wd.refresh()
sleep(5)
for step in self.para:
# 赋值页面类型page
page_type = step.get('page')
# 赋值元素定位类型,并将字符串转为Enum类型
locator_type = get_by_enum(step.get('locator_type'))
# 赋值元素值
locator_value = step.get('locator_value')
# 赋值元素类型,例如:click点击、input输入框等
element_type = step.get('element_type')
# 赋值元素值,例如输入框的输入值
element_value = step.get('element_value')
# 赋值预期结果
expected_result = step.get('expected_result')
# 赋值等待时间
# sleep_time = step.get('sleep_time')
# 赋值操作步骤
step_name = step.get('step')
INFO(
f"步骤名称: {step_name}\n"
)
if element_type == "click":
safe_click((locator_type, locator_value), wd)
sleep(5)
SELENIUM_LOG_SCREEN(wd, "75")
elif element_type == "input":
safe_send_keys((locator_type, locator_value), element_value, wd)
sleep(2)
SELENIUM_LOG_SCREEN(wd, "75")
elif element_type == "SwitchWindow":
# 将字符转换为int类型
element_value = int(element_value)
wd.switch_to.window(wd.window_handles[element_value])
sleep(2)
SELENIUM_LOG_SCREEN(wd, "75")
elif element_type == "login":
# 退出系统登录
safe_click((By.XPATH, "//div[@class='quit']"), wd)
sleep(5)
INFO(f"开始登录,账号为:{element_value[0]},密码为:{element_value[1]}")
safe_send_keys((By.XPATH, "//input[@placeholder='手机号/用户名/邮箱']"), "admin@xty", wd)
safe_send_keys((By.XPATH, "//input[@placeholder='密码']"), "Ubains@4321", wd)
safe_send_keys((By.XPATH, "//input[@placeholder='图形验证']"), "csba", wd)
sleep(2)
INFO("对协议进行勾选")
safe_click((By.XPATH, "//div[@aria-label='提示']//span[contains(text(),'确定')]"), wd)
INFO("已经勾选协议了")
sleep(2)
safe_click((By.XPATH, "//div[@id='pane-1']//div//span[contains(text(),'登录')]"), wd)
INFO("已经点击登录了")
sleep(2)
elif element_type == "getTips":
notify_text = get_notify_text(wd, (locator_type, locator_value))
INFO(f"获取到的提示信息为:{notify_text}")
sleep(2)
CHECK_POINT(f"获取到的提示信息为:{notify_text}", expected_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "75")
elif element_type == "getText":
text = elment_get_text((locator_type, locator_value), wd)
INFO(f"获取到的文本信息为:{text}")
CHECK_POINT(f"获取到的文本信息为:{text}", expected_result in text)
SELENIUM_LOG_SCREEN(wd, "75")
sleep(2)
\ No newline at end of file
......@@ -2,10 +2,6 @@ server_addr: "ngrok.ubsyun.com:9083"
trust_host_root_certs: false
tunnels:
nat1:
remote_port: 32136
proto:
tcp: "127.0.0.1:80"
nat2:
remote_port: 32135
proto:
tcp: "127.0.0.1:8081"
\ No newline at end of file
tcp: "127.0.0.1:81"
remote_port: 31134
\ No newline at end of file
......@@ -9,9 +9,9 @@ import threading
执行指令:
1.打开一个终端输入:
- cd .\统一平台\
- python -m http.server 8081 --directory reports
- python -m http.server 81 --directory reports
2.打开新终端输入:
- cd .\统一平台\ngrok\ngrok-调试主机\
- cd .\统一平台\ngrok\
- .\start.bat
3.再打开一个终端输入:
- cd .\统一平台\
......@@ -58,14 +58,14 @@ def start_workers(num_workers):
start_workers(3)
# 定时执行成都太行项目
# schedule.every().day.at("08:00").do(run_task, run_automation_test, report_title="成都太行项目测试报告", report_url_prefix="http://nat.ubainsyun.com:32135", test_case="成都太行", ding_type="项目功能验证")
# schedule.every().day.at("08: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("08:15").do(run_task, run_automation_test, report_title="重庆长安项目测试报告", report_url_prefix="http://nat.ubainsyun.com:32135", test_case="重庆长安", ding_type="项目功能验证")
#schedule.every().day.at("08:15").do(run_task, run_automation_test, report_title="重庆长安项目测试报告", report_url_prefix="http://nat.ubainsyun.com:31134", test_case="重庆长安", ding_type="项目功能验证")
# 定时执行统一平台标准版
# schedule.every().day.at("08:20").do(run_task, run_automation_test, report_title="统一平台标准版测试报告", report_url_prefix="http://nat.ubainsyun.com:32135", test_case="统一平台", ding_type="标准版巡检")
# schedule.every().day.at("08:20").do(run_task, run_automation_test, report_title="统一平台标准版测试报告", report_url_prefix="http://nat.ubainsyun.com:31134", test_case="统一平台", ding_type="标准版巡检")
# 定时执行新统一平台标准版
schedule.every().day.at("11:30").do(run_task, run_automation_test, report_title="新统一平台测试报告", report_url_prefix="http://nat.ubainsyun.com:32135", test_case="新统一平台", ding_type="标准版巡检")
schedule.every().day.at("11:30").do(run_task, run_automation_test, report_title="新统一平台测试报告", report_url_prefix="http://nat.ubainsyun.com:31134", test_case="新统一平台", ding_type="标准版巡检")
try:
# 无限循环,持续检查并执行计划任务
......
......@@ -2,10 +2,6 @@ server_addr: "ngrok.ubsyun.com:9083"
trust_host_root_certs: false
tunnels:
nat1:
remote_port: 31136
proto:
tcp: "192.168.5.88:80"
nat2:
remote_port: 30135
proto:
tcp: "192.168.1.66:8081"
\ No newline at end of file
tcp: "127.0.0.1:82"
remote_port: 31135
\ No newline at end of file
......@@ -18,7 +18,7 @@ logging.basicConfig(
执行指令:
1.打开一个终端输入:
- cd .\运维集控\项目测试\运维标准版\
- python -m http.server 80 --directory log
- python -m http.server 82 --directory log
2.打开新终端输入:
- cd .\运维集控\项目测试\运维标准版\ngrok\
- .\start.bat
......@@ -66,7 +66,7 @@ def start_workers(num_workers):
# 启动3个工作线程
start_workers(3)
# 运维自动化测试
schedule.every().day.at("16:05").do(run_task, run_automation_test, report_title="运维系统自动化报告", report_url_prefix="http://nat.ubainsyun.com:32136", ding_type="标准版巡检")
schedule.every().day.at("16:05").do(run_task, run_automation_test, report_title="运维系统自动化报告", report_url_prefix="http://nat.ubainsyun.com:31135", ding_type="标准版巡检")
try:
# 无限循环,持续检查并执行计划任务
......
......@@ -83,9 +83,9 @@ def browser_init(login_type):
# EDY电脑
# service = Service(r'C:\Users\EDY\AppData\Local\Programs\Python\Python310\Scripts\chromedriver.exe')
# 云电脑
service = Service(r'E:\Python\Scripts\chromedriver.exe')
# service = Service(r'E:\Python\Scripts\chromedriver.exe')
# 自动化虚拟机
# service = Service(r'C:\Program Files\Python310\Scripts\chromedriver.exe')
service = Service(r'C:\Program Files\Python310\Scripts\chromedriver.exe')
# 尝试创建WebDriver实例并执行初始化操作
try:
# 创建WebDriver实例
......
......@@ -2,10 +2,6 @@ server_addr: "ngrok.ubsyun.com:9083"
trust_host_root_certs: false
tunnels:
nat1:
remote_port: 31134
proto:
tcp: "127.0.0.1:80"
nat2:
remote_port: 31135
proto:
tcp: "127.0.0.1:81"
\ No newline at end of file
tcp: "127.0.0.1:83"
remote_port: 31136
\ No newline at end of file
......@@ -19,20 +19,9 @@ if not os.path.isdir(cases_dir):
调试主机-执行指令:
1.打开一个终端输入:
- cd .\预定系统\
- python -m http.server 81 --directory reports
- python -m http.server 83 --directory reports
2.打开新终端输入:
- cd .\预定系统\ngrok\ngrok-调试主机\
- .\start.bat
3.再打开一个终端输入:
- cd .\预定系统\
- python .\定时执行功能测试.py
自动化运行虚拟机-执行指令:
1.打开一个终端输入:
- cd .\预定系统\
- python -m http.server 81 --directory reports
2.打开新终端输入:
- cd .\预定系统\ngrok\ngrok-自动化运行虚拟机
- cd .\预定系统\ngrok\
- .\start.bat
3.再打开一个终端输入:
- cd .\预定系统\
......@@ -95,19 +84,19 @@ def start_workers(num_workers):
start_workers(3)
# 定时执行预定系统测试任务
schedule.every().day.at("10: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("10:00").do(run_task, run_automation_test, report_title="预定系统测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", test_case="预定系统测试", ding_type="标准版巡检")
schedule.every().day.at("07: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("07:00").do(run_task, run_automation_test, report_title="兰州中石化项目测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", 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:31134", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().monday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31134", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().thursday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31134", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().wednesday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31134", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().tuesday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31134", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().friday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31134", test_case="展厅巡检", ding_type="展厅巡检")
# schedule.every().saturday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31134", test_case="展厅巡检", ding_type="展厅巡检")
# schedule.every().sunday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31134", 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:31136", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().monday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().thursday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().wednesday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().tuesday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().friday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", test_case="展厅巡检", ding_type="展厅巡检")
# schedule.every().saturday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", test_case="展厅巡检", ding_type="展厅巡检")
# schedule.every().sunday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", test_case="展厅巡检", ding_type="展厅巡检")
try:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论