获取上传页面线路测量时间。
This commit is contained in:
Binary file not shown.
@@ -20,7 +20,7 @@ import globals.global_variable as global_variable
|
||||
class UploadConfigPage:
|
||||
def __init__(self, driver, wait, device_id):
|
||||
self.driver = driver
|
||||
self.wait = wait
|
||||
self.wait = WebDriverWait(driver, 2)
|
||||
self.logger = logging.getLogger(__name__)
|
||||
self.more_download_page = MoreDownloadPage(driver, wait,device_id)
|
||||
self.device_id = device_id
|
||||
@@ -139,7 +139,49 @@ class UploadConfigPage:
|
||||
EC.presence_of_element_located((AppiumBy.XPATH, item_container_xpath))
|
||||
)
|
||||
# self.logger.info(f"找到包含断点 {breakpoint_name} 的itemContainer")
|
||||
|
||||
# 1. 获取测量时间并比较是不是今天
|
||||
# 在itemContainer内查找subtitle元素
|
||||
try:
|
||||
subtitle_element = item_container.find_element(
|
||||
AppiumBy.ID,
|
||||
"com.bjjw.cjgc:id/subtitle"
|
||||
)
|
||||
measurement_time_text = subtitle_element.text
|
||||
self.logger.info(f"找到测量时间文本: {measurement_time_text}")
|
||||
|
||||
# 提取时间部分(去掉"测量时间:"前缀)
|
||||
if "测量时间:" in measurement_time_text:
|
||||
# 方法1:使用split提取年月日部分
|
||||
time_str = measurement_time_text.replace("测量时间:", "")
|
||||
# 只取年月日部分(假设格式为 YYYY-MM-DD HH:MM:SS)
|
||||
measurement_date_str = time_str.split()[0] # 取空格前的部分
|
||||
self.logger.info(f"提取到的测量日期: {measurement_date_str}")
|
||||
# if not measurement_date_str == datetime.now().strftime("%Y-%m-%d"): # 测量时间是今天
|
||||
# self.logger.info(f"测量时间不是今天,不点击上传按钮")
|
||||
# return False
|
||||
# 2. 判断测量日期是否允许上传(小于等于今天可以,大于今天不行)
|
||||
try:
|
||||
# 将字符串日期转换为datetime对象进行比较
|
||||
measurement_date = datetime.strptime(measurement_date_str, "%Y-%m-%d").date()
|
||||
today_date = datetime.now().date()
|
||||
|
||||
self.logger.info(f"测量日期: {measurement_date}, 今天日期: {today_date}")
|
||||
|
||||
# 判断逻辑:测量日期 > 今天 → 不允许上传
|
||||
if measurement_date > today_date:
|
||||
self.logger.warning(f"测量日期 {measurement_date} 是未来日期,不允许上传")
|
||||
return False
|
||||
|
||||
# 测量日期 <= 今天 → 允许上传
|
||||
self.logger.info(f"✓ 测量日期 {measurement_date} 小于等于今天,允许上传")
|
||||
|
||||
except ValueError as e:
|
||||
self.logger.error(f"日期格式解析失败: {measurement_date_str}, 错误: {str(e)}")
|
||||
return False
|
||||
except Exception as e:
|
||||
self.logger.warning(f"获取测量时间失败: {str(e)};不点击线路{breakpoint_name}的上传按钮")
|
||||
return False
|
||||
|
||||
# 在itemContainer中查找上传按钮
|
||||
upload_btn = item_container.find_element(
|
||||
AppiumBy.ID,
|
||||
@@ -151,17 +193,7 @@ class UploadConfigPage:
|
||||
self.logger.info(f"已点击断点 {breakpoint_name} 的上传按钮")
|
||||
|
||||
# 等待上传操作开始
|
||||
time.sleep(3)
|
||||
|
||||
# # 检查上传是否开始
|
||||
# try:
|
||||
# upload_indicator = WebDriverWait(self.driver, 20).until(
|
||||
# EC.presence_of_element_located((AppiumBy.XPATH, "//*[contains(@text, '上传') or contains(@text, 'Upload')]"))
|
||||
# )
|
||||
# self.logger.info(f"上传操作已开始: {upload_indicator.text}")
|
||||
# except TimeoutException:
|
||||
# self.logger.warning("未检测到明确的上传开始提示,但按钮点击已完成")
|
||||
|
||||
# time.sleep(3)
|
||||
return True
|
||||
|
||||
except TimeoutException:
|
||||
@@ -1862,14 +1894,14 @@ class UploadConfigPage:
|
||||
return False
|
||||
|
||||
|
||||
# 表达填写完成,点击"保存上传"并处理弹窗
|
||||
if not self.click_save_upload_and_handle_dialogs():
|
||||
self.logger.error("点击保存上传并处理弹窗失败")
|
||||
return False
|
||||
# # 表达填写完成,点击"保存上传"并处理弹窗
|
||||
# if not self.click_save_upload_and_handle_dialogs():
|
||||
# self.logger.error("点击保存上传并处理弹窗失败")
|
||||
# return False
|
||||
|
||||
# # 暂不上传,使用返回按钮替代。
|
||||
# self.driver.back()
|
||||
# return True
|
||||
# 暂不上传,使用返回按钮替代。
|
||||
self.driver.back()
|
||||
return True
|
||||
|
||||
|
||||
# 等待上传,查看loading弹窗。没有就下一个
|
||||
|
||||
Reference in New Issue
Block a user