修正驱动和修改变量值

This commit is contained in:
2026-06-16 10:26:43 +08:00
parent de5173ded6
commit a41ba4501f
9 changed files with 45 additions and 30 deletions

View File

@@ -109,20 +109,25 @@ class DeviceAutomation:
def init_driver(self):
"""初始化Appium驱动"""
try:
try:
if not driver_utils.check_session_valid(self.driver, self.device_id):
logging.warning(f"设备 {self.device_id} 会话无效,尝试重新连接驱动...")
self.driver, self.wait = driver_utils.reconnect_driver(self.device_id, self.driver)
if not self.driver:
logging.error(f"设备 {self.device_id} 驱动重连失败")
return False
except Exception as inner_e:
logging.warning(f"设备 {self.device_id} 检查会话状态时出错: {str(inner_e)}")
return False
# # 使用全局函数初始化驱动
if not self.driver:
logging.info(f"设备 {self.device_id} 驱动实例为空,初始化新驱动...")
self.driver, self.wait = driver_utils.init_appium_driver(self.device_id)
if not self.driver:
logging.error(f"设备 {self.device_id} 驱动初始化失败")
return False
else:
try:
if not driver_utils.check_session_valid(self.driver, self.device_id):
logging.warning(f"设备 {self.device_id} 会话无效,尝试重新连接驱动...")
self.driver, self.wait = driver_utils.reconnect_driver(self.device_id, self.driver)
if not self.driver:
logging.error(f"设备 {self.device_id} 驱动重连失败")
return False
except Exception as inner_e:
logging.warning(f"设备 {self.device_id} 检查会话状态时出错: {str(inner_e)}")
return False
self.results_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_results')
# self.driver, self.wait = driver_utils.init_appium_driver(self.device_id)
# 初始化页面对象
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)
@@ -172,7 +177,7 @@ class DeviceAutomation:
login_success = False
for attempt in range(max_retries_login + 1):
if self.login_page.login("czsczq115ykl"):
if self.login_page.login("cdwzq3liangchaoyong"):
login_success = True
break
else:
@@ -207,11 +212,11 @@ class DeviceAutomation:
# task_data = apis.get_measurement_task()
# logging.info(f"设备 {self.device_id} 获取到的测量任务: {task_data}")
task_data = {
"id": 21,
"user_name": "czsczq115ykl",
"name": "czsczq115ykl",
"line_num": "L220179",
"line_name": "CZSCZQ-11-五工区-德达隧道6#斜井左线-DK632+707-DK632+705-山区",
"id": 1,
"user_name": "cdwzq3liangchaoyong",
"name": "cdwzq3liangchaoyong",
"line_num": "L141037",
"line_name": "CDWZQ-3标-区间路基114号-2-434975-435400-平原",
"remaining": "0",
"status": 0
}

View File

@@ -88,11 +88,11 @@ def get_breakpoint_list():
else:
logging.info(f"接口返回错误: {result.get('code')}")
return [{
"id": 21,
"user_name": "czsczq115ykl",
"name": "czsczq115ykl",
"line_num": "L220179",
"line_name": "CZSCZQ-11-五工区-德达隧道6#斜井左线-DK632+707-DK632+705-山区",
"id": 1,
"user_name": "cdwzq3liangchaoyong",
"name": "cdwzq3liangchaoyong",
"line_num": "L141037",
"line_name": "CDWZQ-3标-区间路基114号-2-434975-435400-平原",
"status": 3
}]
else:

View File

@@ -1,9 +1,9 @@
# 全局变量
GLOBAL_DEVICE_ID = "" # 设备ID
GLOBAL_USERNAME = "czyuzongwen" # 用户名
GLOBAL_ACCOUNT_ID = "" # 账号ID
GLOBAL_CURRENT_PROJECT_NAME = "CZSCZQ-11-五工区-德达隧道6#斜井左线-DK632+707-DK632+705-山区" # 当前测试项目名称
GLOBAL_LINE_NUM = "L220179" # 线路编码
GLOBAL_USERNAME = "cdwzq3liangchaoyong" # 用户名
GLOBAL_ACCOUNT_ID = 1 # 账号ID
GLOBAL_CURRENT_PROJECT_NAME = "CDWZQ-3标-区间路基114号-2-434975-435400-平原" # 当前测试项目名称
GLOBAL_LINE_NUM = "L141037" # 线路编码
GLOBAL_BREAKPOINT_STATUS_CODES = [0,3] # 要获取的断点状态码列表
GLOBAL_UPLOAD_BREAKPOINT_LIST = []
GLOBAL_UPLOAD_BREAKPOINT_DICT = {}

View File

@@ -142,9 +142,14 @@ class LoginPage:
logging.info(f"匹配到账号信息username={existing_username}, account_id={account_id}")
else:
logging.warning(f"账号 {existing_username} 未返回 account_id已设为 False")
else:
logging.error(f"未找到与用户名 '{existing_username}' 匹配的账户信息")
return False
if not password:
logging.error(f"获取到的密码为空,无法登录")
return False
password_field.send_keys(password)
# 4. 可选:隐藏键盘
@@ -239,9 +244,14 @@ class LoginPage:
logging.info(f"匹配到账号信息username={existing_username}, account_id={account_id}")
else:
logging.warning(f"账号 {existing_username} 未返回 account_id已设为 False")
else:
logging.error(f"未找到与用户名 '{existing_username}' 匹配的账户信息")
return False
if not password:
logging.error(f"获取到的密码为空,无法登录")
return False
password_field.send_keys(password)
# 4. 可选:隐藏键盘