diff --git a/__pycache__/check_station.cpython-312.pyc b/__pycache__/check_station.cpython-312.pyc index cc79aec..1216035 100644 Binary files a/__pycache__/check_station.cpython-312.pyc and b/__pycache__/check_station.cpython-312.pyc differ diff --git a/actions.py b/actions.py index fbbb1af..9f197e7 100644 --- a/actions.py +++ b/actions.py @@ -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 } diff --git a/globals/__pycache__/apis.cpython-312.pyc b/globals/__pycache__/apis.cpython-312.pyc index 2b1e579..60df833 100644 Binary files a/globals/__pycache__/apis.cpython-312.pyc and b/globals/__pycache__/apis.cpython-312.pyc differ diff --git a/globals/__pycache__/global_variable.cpython-312.pyc b/globals/__pycache__/global_variable.cpython-312.pyc index 2207843..af44412 100644 Binary files a/globals/__pycache__/global_variable.cpython-312.pyc and b/globals/__pycache__/global_variable.cpython-312.pyc differ diff --git a/globals/apis.py b/globals/apis.py index b3d364d..053bc81 100644 --- a/globals/apis.py +++ b/globals/apis.py @@ -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: diff --git a/globals/global_variable.py b/globals/global_variable.py index b24c5b2..f120abb 100644 --- a/globals/global_variable.py +++ b/globals/global_variable.py @@ -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 = {} diff --git a/page_objects/__pycache__/login_page.cpython-312.pyc b/page_objects/__pycache__/login_page.cpython-312.pyc index bb4cc2d..ece8380 100644 Binary files a/page_objects/__pycache__/login_page.cpython-312.pyc and b/page_objects/__pycache__/login_page.cpython-312.pyc differ diff --git a/page_objects/__pycache__/section_mileage_config_page.cpython-312.pyc b/page_objects/__pycache__/section_mileage_config_page.cpython-312.pyc index 13d736d..4bb60dd 100644 Binary files a/page_objects/__pycache__/section_mileage_config_page.cpython-312.pyc and b/page_objects/__pycache__/section_mileage_config_page.cpython-312.pyc differ diff --git a/page_objects/login_page.py b/page_objects/login_page.py index 2b5956e..5439194 100644 --- a/page_objects/login_page.py +++ b/page_objects/login_page.py @@ -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. 可选:隐藏键盘