Add cross-flow automation test and tone down log/comment wording

- main_router: add run_automation_test that runs each site's download
  flows in a cross sequence (expected/actual) plus a pass/fail report
  with timings; expose it as menu [8]
- Site download functions now return False on their exception paths so
  the test harness can record failures (baishi also flags config-read
  failure)
- Replace overblown log/comment phrasing across all modules with plain
  statements; trim docstrings

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-06-20 23:33:22 +08:00
parent ab3f25a10e
commit 229e474b58
5 changed files with 298 additions and 191 deletions

View File

@@ -21,19 +21,19 @@ def baishi_download_undelivered_data(page):
# 打开基础服务菜单面板
page.locator("div.nav-level1", has_text="基础服务").click()
# 【重要修复】:通过限制在菜单面板nav-level2-wrapper内查找
# 完美避开页面右侧同名 Tab 标签页的干扰
# 限制在菜单面板nav-level2-wrapper内查找
# 避免命中右侧同名标签页
page.locator(".nav-level2-wrapper").locator(
"a", has_text="扫描综合查询"
).click()
# 验证表格主界面加载完毕
page.get_by_role("tab", name="实时扫描率").wait_for(state="visible")
print("✅ 扫描综合查询界面加载完毕")
print("✅ 扫描综合查询界面加载")
# 2. 精准定位并点击【到/接件扫描 -> 当日 -> 未扫】的数字控件
print(">> 正在解析表格,提取当日到件未扫明细...")
# 表头结构复杂,精准定位第一行数据的第 13 列(索引 12
# 定位第一行数据的第 13 列(索引 12
target_cell = page.locator(".ant-table-tbody > tr").first.locator("td").nth(12)
# 特殊情况处理检查未扫数量是否为0
@@ -51,15 +51,15 @@ def baishi_download_undelivered_data(page):
page.wait_for_timeout(1000)
# 3. 触发导出设置模态框
print(">> 正在呼出导出配置面板...")
# 锁定在明细区域内的导出按钮,防止误点主表导出
print(">> 正在打开导出配置面板...")
# 使用明细区域内的导出按钮,避免误点主表导出
detail_section.locator(".export-wrap a[title='导出']").click()
# 验证模态框弹出
page.locator(".ant-modal-title", has_text="导出设置").wait_for(state="visible")
# 4. 加载 YAML 配置并输入密码
print(">> 正在读取本地配置文件并进行授权验证...")
print(">> 正在读取配置并填写密码...")
password = ""
try:
with open(CONFIG_PATH, "r", encoding="utf-8") as f:
@@ -72,14 +72,14 @@ def baishi_download_undelivered_data(page):
)
except Exception as e:
print(f" ⚠️ 读取 config.yaml 失败,请确保文件存在且格式正确: {e}")
return
return False
page.get_by_placeholder("请输入登录密码").fill(password)
# 5. 执行最终下载
print(">> 验证就绪,正在触发下载...")
print(">> 正在下载...")
with page.expect_download() as download_info:
# 精准锁定模态框底部的“导 出”按钮
# 点击模态框底部的“导 出”按钮
page.locator(".ant-modal-footer").get_by_role(
"button", name="导 出"
).click()
@@ -93,11 +93,12 @@ def baishi_download_undelivered_data(page):
download.save_as(save_path)
print(f"====================================================")
print(f" 🎉 恭喜!数据提取成功")
print(f" ⬇️ 文件已落盘: {save_path}")
print(f" 提取成功")
print(f" 已下载: {save_path}")
print(f"====================================================")
print("\n🎉 【百世 - 应到未到数据提取】流程测试完毕!")
print("\n【百世 - 应到未到数据提取】流程结束。")
except Exception as e:
print(f"\n❌ 任务执行过程中发生异常: {e}")
return False