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

更新展厅巡检定时任务。通过覆盖的方式将appium的截图替换掉hytest的截图,从而实现appium的测试报告生成。

上级 a8255348
...@@ -104,3 +104,5 @@ ...@@ -104,3 +104,5 @@
- 补充MQTT的消息监听,监听到消息后,会通过日志输出消息体内容,可用于所有预定项目测试使用。 - 补充MQTT的消息监听,监听到消息后,会通过日志输出消息体内容,可用于所有预定项目测试使用。
- 补充富创项目的MQTT消息监听,监听到消息后,会通过日志输出消息体内容,可用于富创项目测试替代第三方工具使用。 - 补充富创项目的MQTT消息监听,监听到消息后,会通过日志输出消息体内容,可用于富创项目测试替代第三方工具使用。
- 处理富创项目的MQTT预约、修改和删除会议消息体,增加代码可维护性。补充标准版安卓信息的监听代码。 - 处理富创项目的MQTT预约、修改和删除会议消息体,增加代码可维护性。补充标准版安卓信息的监听代码。
30. 2024-12-14
- 更新展厅巡检定时任务。通过覆盖的方式将appium的截图替换掉hytest的截图,从而实现appium的测试报告生成。
\ No newline at end of file
...@@ -12,8 +12,9 @@ from 预定系统.Base.base import * ...@@ -12,8 +12,9 @@ from 预定系统.Base.base import *
def suite_setup(): def suite_setup():
STEP(1, "初始化浏览器") STEP(1, "初始化浏览器")
login_url = 'https://192.168.5.218/#/login/logindf' # login_url = 'https://192.168.5.218/#/login/logindf'
login_ngrok_url = "https://nat.ubainsyun.com:11046" # login_ngrok_url = "https://nat.ubainsyun.com:11046"
login_url = 'http://192.168.5.200:8080/#/login/logindf'
browser_init(login_url) browser_init(login_url)
wd = GSTORE['wd'] wd = GSTORE['wd']
......
...@@ -18,8 +18,9 @@ except ModuleNotFoundError as e: ...@@ -18,8 +18,9 @@ except ModuleNotFoundError as e:
def suite_setup(): def suite_setup():
STEP(1, "初始化浏览器") STEP(1, "初始化浏览器")
login_url = 'https://192.168.5.218/#/login/logindf' # login_url = 'https://192.168.5.218/#/login/logindf'
login_ngrok_url = "https://nat.ubainsyun.com:11046" # login_ngrok_url = "https://nat.ubainsyun.com:11046"
login_url = 'http://192.168.5.200:8080/#/login/logindf'
browser_init(login_url) browser_init(login_url)
wd = GSTORE['wd'] wd = GSTORE['wd']
......
...@@ -18,8 +18,9 @@ except ModuleNotFoundError as e: ...@@ -18,8 +18,9 @@ except ModuleNotFoundError as e:
def suite_setup(): def suite_setup():
STEP(1, "初始化浏览器") STEP(1, "初始化浏览器")
login_url = 'https://192.168.5.218/#/login/logindf' # login_url = 'https://192.168.5.218/#/login/logindf'
login_ngrok_url = "https://nat.ubainsyun.com:11046" # login_ngrok_url = "https://nat.ubainsyun.com:11046"
login_url = 'http://192.168.5.200:8080/#/login/logindf'
browser_init(login_url) browser_init(login_url)
wd = GSTORE['wd'] wd = GSTORE['wd']
......
...@@ -18,8 +18,9 @@ except ModuleNotFoundError as e: ...@@ -18,8 +18,9 @@ except ModuleNotFoundError as e:
def suite_setup(): def suite_setup():
STEP(1, "初始化浏览器") STEP(1, "初始化浏览器")
login_url = 'https://192.168.5.218/#/login/logindf' # login_url = 'https://192.168.5.218/#/login/logindf'
login_ngrok_url = "https://nat.ubainsyun.com:11046" # login_ngrok_url = "https://nat.ubainsyun.com:11046"
login_url = 'http://192.168.5.200:8080/#/login/logindf'
browser_init(login_url) browser_init(login_url)
wd = GSTORE['wd'] wd = GSTORE['wd']
admin_login("admin@ZDH", "Ubains@4321") admin_login("admin@ZDH", "Ubains@4321")
......
...@@ -26,6 +26,7 @@ class Exhibition_hall_inspection_000x: ...@@ -26,6 +26,7 @@ class Exhibition_hall_inspection_000x:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 会议预约测试报告 --report_url_prefix http://192.168.1.225 --test 展厅巡检_0** 2.hytest --report_title 会议预约测试报告 --report_url_prefix http://192.168.1.225 --test 展厅巡检_0**
""" """
tags = ['展厅巡检']
ddt_cases = read_csv_data(csv_file_path) ddt_cases = read_csv_data(csv_file_path)
def teststeps(self): def teststeps(self):
......
from time import sleep
from appium.webdriver.common.appiumby import AppiumBy from appium.webdriver.common.appiumby import AppiumBy
from hytest import SELENIUM_LOG_SCREEN
from 预定系统.Base.app_base import * from 预定系统.Base.app_base import *
import logging import logging
from time import sleep
# 配置日志记录 # 配置日志记录
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
def app_txcent_test(): class Exhibition_hall_inspection_000x:
"""
执行指令:
1.cd 预定系统
2.hytest --report_title 会议预约测试报告 --report_url_prefix http://192.168.1.225 --test 展厅巡检_0**
"""
tags = ['展厅巡检_腾讯会议']
def teststeps(self):
app_drive = None app_drive = None
try: try:
# 腾讯:"com.tencent.wemeet.app" ".StartupActivity" # 腾讯:"com.tencent.wemeet.app" ".StartupActivity"
app_drive = app_setup_driver("Android", "7.1.2", "127.0.0.1:62001", "com.tencent.wemeet.app", ".StartupActivity") app_drive = app_setup_driver("Android", "7.1.2", "127.0.0.1:62001", "com.tencent.wemeet.app",
".StartupActivity")
app_drive.implicitly_wait(20) # 设置缺省等待时间 app_drive.implicitly_wait(20) # 设置缺省等待时间
# 使用显式等待来等待元素出现 # 使用显式等待来等待元素出现
...@@ -20,7 +27,8 @@ def app_txcent_test(): ...@@ -20,7 +27,8 @@ def app_txcent_test():
# 定位第一场会议按钮元素,并点击按钮 # 定位第一场会议按钮元素,并点击按钮
logging.info("尝试定位【会议名称】按钮元素,并点击按钮") logging.info("尝试定位【会议名称】按钮元素,并点击按钮")
meeting_button = app_drive.find_element(AppiumBy.XPATH, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.view.ViewGroup/android.widget.LinearLayout[1]/android.view.ViewGroup/android.widget.RelativeLayout/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[4]/android.view.ViewGroup/androidx.appcompat.widget.LinearLayoutCompat[1]/android.view.ViewGroup/android.widget.TextView") # meeting_button = app_drive.find_element(AppiumBy.XPATH,"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.view.ViewGroup/android.widget.LinearLayout[1]/android.view.ViewGroup/android.widget.RelativeLayout/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[4]/android.view.ViewGroup/androidx.appcompat.widget.LinearLayoutCompat[1]/android.view.ViewGroup/android.widget.TextView")
meeting_button = app_drive.find_element(AppiumBy.XPATH,"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.view.ViewGroup/android.widget.LinearLayout[1]/android.view.ViewGroup/android.widget.RelativeLayout/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[1]/android.view.ViewGroup/androidx.appcompat.widget.LinearLayoutCompat/android.view.ViewGroup/android.widget.TextView")
logging.info("定位会议成功") logging.info("定位会议成功")
# 点击【加入会议】按钮 # 点击【加入会议】按钮
meeting_button.click() meeting_button.click()
...@@ -29,22 +37,94 @@ def app_txcent_test(): ...@@ -29,22 +37,94 @@ def app_txcent_test():
# 点击【加入会议】按钮 # 点击【加入会议】按钮
logging.info("尝试定位【加入会议】按钮元素,并点击按钮") logging.info("尝试定位【加入会议】按钮元素,并点击按钮")
join_meeting_button = app_drive.find_element(AppiumBy.XPATH, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/androidx.appcompat.widget.LinearLayoutCompat/androidx.appcompat.widget.LinearLayoutCompat/android.widget.TextView") join_meeting_button = app_drive.find_element(AppiumBy.XPATH,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/androidx.appcompat.widget.LinearLayoutCompat/androidx.appcompat.widget.LinearLayoutCompat/android.widget.TextView")
logging.info("定位【加入会议】按钮成功") logging.info("定位【加入会议】按钮成功")
join_meeting_button.click() join_meeting_button.click()
logging.info("点击【加入会议】按钮成功") logging.info("点击【加入会议】按钮成功")
sleep(8) sleep(8)
app_drive.get_screenshot_as_file( app_drive.get_screenshot_as_file(
r"D:\GithubData\自动化测试\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Tx_meeting\会场控制截屏.png") r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Tx_meeting\会场画面截屏.png")
sleep(8)
except Exception as e: except Exception as e:
logging.error(f"发生错误: {e}", exc_info=True) logging.error(f"发生错误: {e}", exc_info=True)
finally: finally:
if app_drive: if app_drive:
input('**** 按任意键退出..')
app_drive.quit() app_drive.quit()
logging.info("驱动程序已退出。") logging.info("驱动程序已退出。")
if __name__ == '__main__':
app_txcent_test() # from appium.webdriver.common.appiumby import AppiumBy
# from 预定系统.Base.app_base import *
# import logging
# from time import sleep
# import unittest
# import os
# from HtmlTestRunner import HTMLTestRunner
#
# # 配置日志记录
# logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
#
# class TestAppTXCent(unittest.TestCase):
# def setUp(self):
# self.app_drive = None
# try:
# # 腾讯:"com.tencent.wemeet.app" ".StartupActivity"
# self.app_drive = app_setup_driver("Android", "7.1.2", "127.0.0.1:62001", "com.tencent.wemeet.app", ".StartupActivity")
# self.app_drive.implicitly_wait(20) # 设置缺省等待时间
# except Exception as e:
# logging.error(f"初始化驱动程序时发生错误: {e}", exc_info=True)
# self.fail(f"初始化驱动程序时发生错误: {e}")
#
# def tearDown(self):
# if self.app_drive:
# input('**** 按任意键退出..')
# self.app_drive.quit()
# logging.info("驱动程序已退出。")
#
# def test_app_txcent(self):
# try:
# # 使用显式等待来等待元素出现
# logging.info("等待登录页加载...")
#
# # 定位第一场会议按钮元素,并点击按钮
# logging.info("尝试定位【会议名称】按钮元素,并点击按钮")
# meeting_button = self.app_drive.find_element(AppiumBy.XPATH, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.view.ViewGroup/android.widget.LinearLayout[1]/android.view.ViewGroup/android.widget.RelativeLayout/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[4]/android.view.ViewGroup/androidx.appcompat.widget.LinearLayoutCompat[1]/android.view.ViewGroup/android.widget.TextView")
# logging.info("定位会议成功")
# # 点击【加入会议】按钮
# meeting_button.click()
# logging.info("点击【会议】按钮成功")
# sleep(2)
#
# # 点击【加入会议】按钮
# logging.info("尝试定位【加入会议】按钮元素,并点击按钮")
# join_meeting_button = self.app_drive.find_element(AppiumBy.XPATH, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/androidx.appcompat.widget.LinearLayoutCompat/androidx.appcompat.widget.LinearLayoutCompat/android.widget.TextView")
# logging.info("定位【加入会议】按钮成功")
# join_meeting_button.click()
# logging.info("点击【加入会议】按钮成功")
# sleep(8)
#
# # 截图并保存
# screenshot_path = os.path.join(os.getcwd(), "reports", "imgs", "Exhibit_Inspect", "Tx_meeting", "会场控制截屏.png")
# os.makedirs(os.path.dirname(screenshot_path), exist_ok=True)
# self.app_drive.get_screenshot_as_file(screenshot_path)
# logging.info(f"截图已保存到: {screenshot_path}")
# except Exception as e:
# logging.error(f"发生错误: {e}", exc_info=True)
# self.fail(f"测试过程中发生错误: {e}")
#
# if __name__ == '__main__':
# # 创建测试套件
# suite = unittest.TestSuite()
# suite.addTest(TestAppTXCent('test_app_txcent'))
#
# # 定义报告文件路径
# report_path = os.path.join(os.getcwd(), "reports", "Exhibit_Inspect", "Tx_meeting", "test_report.html")
# os.makedirs(os.path.dirname(report_path), exist_ok=True)
#
# # 运行测试并生成报告
# with open(report_path, 'wb') as f:
# runner = HTMLTestRunner(stream=f, title='腾讯会议自动化测试报告', description='测试报告详情')
# runner.run(suite)
...@@ -17,4 +17,5 @@ def suite_setup(): ...@@ -17,4 +17,5 @@ def suite_setup():
browser_init(login_exhibit_url) browser_init(login_exhibit_url)
wd = GSTORE['wd'] wd = GSTORE['wd']
admin_login("admin@huazhao", "huazhao@1234") admin_login("Test02", "ubains@123")
\ No newline at end of file SELENIUM_LOG_SCREEN(wd,"50%","Exhibit_Inspect","Tx_meeting","会场画面截屏")
\ No newline at end of file
...@@ -13,8 +13,9 @@ from 预定系统.Base.base import * ...@@ -13,8 +13,9 @@ from 预定系统.Base.base import *
def suite_setup(): def suite_setup():
STEP(1, "初始化浏览器") STEP(1, "初始化浏览器")
login_url = 'https://192.168.5.218/#/login/logindf' # login_url = 'https://192.168.5.218/#/login/logindf'
login_ngrok_url = "https://nat.ubainsyun.com:11046" # login_ngrok_url = "https://nat.ubainsyun.com:11046"
login_url = 'http://192.168.5.200:8080/#/login/logindf'
browser_init(login_url) browser_init(login_url)
def suite_teardown(): def suite_teardown():
......
...@@ -13,8 +13,9 @@ from 预定系统.Base.base import * ...@@ -13,8 +13,9 @@ from 预定系统.Base.base import *
def suite_setup(): def suite_setup():
STEP(1, "初始化浏览器") STEP(1, "初始化浏览器")
login_url = 'https://192.168.5.218/#/login/logindf' # login_url = 'https://192.168.5.218/#/login/logindf'
login_ngrok_url = "https://nat.ubainsyun.com:11046" # login_ngrok_url = "https://nat.ubainsyun.com:11046"
login_url = 'http://192.168.5.200:8080/#/login/logindf'
browser_init(login_url) browser_init(login_url)
wd = GSTORE['wd'] wd = GSTORE['wd']
......
...@@ -16,8 +16,9 @@ except ModuleNotFoundError as e: ...@@ -16,8 +16,9 @@ except ModuleNotFoundError as e:
def suite_setup(): def suite_setup():
STEP(1, "初始化浏览器") STEP(1, "初始化浏览器")
login_url = 'https://192.168.5.218/#/login/logindf' # login_url = 'https://192.168.5.218/#/login/logindf'
login_ngrok_url = "https://nat.ubainsyun.com:11046" # login_ngrok_url = "https://nat.ubainsyun.com:11046"
login_url = 'http://192.168.5.200:8080/#/login/logindf'
browser_init(login_url) browser_init(login_url)
wd = GSTORE['wd'] wd = GSTORE['wd']
......
...@@ -10,8 +10,9 @@ from 预定系统.Base.base import * ...@@ -10,8 +10,9 @@ from 预定系统.Base.base import *
def suite_setup(): def suite_setup():
STEP(1, "初始化浏览器") STEP(1, "初始化浏览器")
login_url = 'https://192.168.5.218/#/login/logindf' # login_url = 'https://192.168.5.218/#/login/logindf'
login_ngrok_url = "https://nat.ubainsyun.com:11046" # login_ngrok_url = "https://nat.ubainsyun.com:11046"
login_url = 'http://192.168.5.200:8080/#/login/logindf'
browser_init(login_url) browser_init(login_url)
wd = GSTORE['wd'] wd = GSTORE['wd']
......
...@@ -68,7 +68,12 @@ start_workers(3) ...@@ -68,7 +68,12 @@ start_workers(3)
# 定义每天定时执行的任务 # 定义每天定时执行的任务
# 每天早上07:50执行后台系统设置功能测试 # 每天早上07:50执行后台系统设置功能测试
schedule.every().day.at("07:50").do(run_task, run_automation_test, report_title="预定系统_后台管理功能_测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="后台管理功能") schedule.every().saturday.at("12:00").do(run_task, run_automation_test, report_title="预定系统_后台管理功能_测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="后台管理功能")
schedule.every().day.at("08:15").do(run_task, run_automation_test, report_title="展厅巡检_会议预约测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检")
schedule.every().day.at("08:25").do(run_task, run_automation_test, report_title="展厅巡检_腾讯终端入会测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检_腾讯会议")
try: try:
# 无限循环,持续检查并执行计划任务 # 无限循环,持续检查并执行计划任务
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论