修改截图保存文件夹

This commit is contained in:
2026-02-10 14:41:13 +08:00
parent 4e49793416
commit 6274c83dd5
12 changed files with 437 additions and 306 deletions

18
main.py
View File

@@ -16,9 +16,7 @@ import permissions # 导入权限处理模块
import globals.apis as apis
from globals.driver_utils import init_appium_driver, ensure_appium_server_running, safe_quit_driver, is_app_launched, launch_app_manually
from page_objects.login_page import LoginPage
from page_objects.download_tabbar_page import DownloadTabbarPage
from page_objects.screenshot_page import ScreenshotPage
from page_objects.upload_config_page import UploadConfigPage
from page_objects.more_download_page import MoreDownloadPage
@@ -35,8 +33,14 @@ logging.basicConfig(
class DeviceAutomation(object):
def __init__(self, device_id=None):
def __init__(self, device_id=None, project_name=None):
self.device_id = device_id
self.project_name = project_name
# 设置项目名称到全局变量
if project_name:
global_variable.set_current_project_name(project_name)
logging.info(f"设备 {self.device_id} 已设置项目名称: {project_name}")
# 初始化权限
if permissions.grant_appium_permissions(self.device_id):
@@ -62,9 +66,7 @@ class DeviceAutomation(object):
# 初始化页面对象
logging.info(f"设备 {self.device_id} 开始初始化页面对象")
self.login_page = LoginPage(self.driver, self.wait)
self.download_tabbar_page = DownloadTabbarPage(self.driver, self.wait, self.device_id)
self.screenshot_page = ScreenshotPage(self.driver, self.wait, self.device_id)
self.upload_config_page = UploadConfigPage(self.driver, self.wait, self.device_id)
self.more_download_page = MoreDownloadPage(self.driver, self.wait,self.device_id)
logging.info(f"设备 {self.device_id} 所有页面对象初始化完成")
@@ -246,13 +248,15 @@ class DeviceAutomation(object):
safe_quit_driver(getattr(self, 'driver', None), self.device_id)
@staticmethod
def start_upload(device_id=None, upload_time=None):
def start_upload(device_id=None, upload_time=None, project_name=None):
"""
供其他页面或模块调用的静态方法
执行完整的自动化流程
参数:
device_id: 可选的设备ID如果为None则自动获取
upload_time: 上传时间
project_name: 项目名称
返回:
bool: 自动化流程执行结果True/False
@@ -260,7 +264,7 @@ class DeviceAutomation(object):
automation = None
try:
# 创建自动化实例
automation = DeviceAutomation(device_id=device_id)
automation = DeviceAutomation(device_id=device_id, project_name=project_name)
# 执行自动化流程
success = automation.run_automation()