refactor(pages): PO 层框架化 — 细粒度操作 + 显式等待 + 消除静默吞异常

DriverFreightFlowPage (APP):
- 流程方法拆为单一职责的细粒度操作(open_freight_tab/fill_quantity/upload_photo_from_album/...),
  流程方法仅做编排,公共 API 不变,用例零改动
- 移除全部 implicitly_wait 全局副作用,每步显式等待目标元素
- 容错点击(已知晓/确定)改为 _tap_by_text_if_present,跳过时记录 warning

FreightAccountingPage (Web):
- _go/_click_search 改显式等待(搜索框出现/列表数据行或空态),替代固定 2s/1s sleep
- 表格等待升级为 td:visible,避开 vxe-table 固定列隐藏占位单元格
- 点击行操作按钮后显式等待弹窗出现,替代固定 800ms
- 车队长下拉选择改显式等待下拉项渲染
- 可选弹窗操作统一收敛到 _try_click,跳过时记录 warning;关键确认按钮保持严格

两条 E2E 用例在真实环境回归通过(TC-D2S-001 116s / TC-D2S-002 112s)。
This commit is contained in:
xst
2026-09-02 11:59:46 +08:00
parent 6ee7ade67d
commit 2aca405267
310 changed files with 78629 additions and 157 deletions
+130
View File
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?><testsuites name="pytest tests"><testsuite name="pytest" errors="0" failures="4" skipped="0" tests="5" time="383.862" timestamp="2026-09-02T09:53:58.487570+08:00" hostname="yunba-126"><testcase classname="cross_end.test_driver_to_settlement.TestDriverToSettlement" name="test_driver_to_settlement_full_flow" time="73.097"><failure message="RuntimeError: 运费核算 SQL 重试失败!单号: RHJC040026090100010951040132, 错误: 'database'">tests\cross_end\test_driver_to_settlement.py:126: in &lt;lambda&gt;
retry_sql=lambda: update_risk_control_status(transport_order_no, status=1),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests\core\db_helper.py:75: in update_risk_control_status
return execute_sql(sql, (status, order_code), config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests\core\db_helper.py:32: in execute_sql
conn = get_connection(config)
^^^^^^^^^^^^^^^^^^^^^^
tests\core\db_helper.py:27: in get_connection
return pymysql.connect(**_resolve_config(config))
^^^^^^^^^^^^^^^^^^^^^^^
tests\core\db_helper.py:20: in _resolve_config
cfg = dict(load_config()["database"])
^^^^^^^^^^^^^^^^^^^^^^^^^
E KeyError: 'database'
During handling of the above exception, another exception occurred:
tests\cross_end\test_driver_to_settlement.py:124: in test_driver_to_settlement_full_flow
admin_accounting.do_freight_accounting(
tests\pages\admin\freight_accounting_page.py:149: in do_freight_accounting
raise RuntimeError(f"运费核算 SQL 重试失败!单号: {order_no}, 错误: {e}")
E RuntimeError: 运费核算 SQL 重试失败!单号: RHJC040026090100010951040132, 错误: 'database'</failure></testcase><testcase classname="cross_end.test_driver_to_settlement.TestDriverToSettlementTeamLeader" name="test_driver_to_settlement_team_leader_flow" time="65.581"><failure message="RuntimeError: 运费核算 SQL 重试失败!单号: RHJC040026090100010952080133, 错误: 'database'">tests\cross_end\test_driver_to_settlement.py:239: in &lt;lambda&gt;
retry_sql=lambda: update_risk_control_status(transport_order_no, status=1),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests\core\db_helper.py:75: in update_risk_control_status
return execute_sql(sql, (status, order_code), config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests\core\db_helper.py:32: in execute_sql
conn = get_connection(config)
^^^^^^^^^^^^^^^^^^^^^^
tests\core\db_helper.py:27: in get_connection
return pymysql.connect(**_resolve_config(config))
^^^^^^^^^^^^^^^^^^^^^^^
tests\core\db_helper.py:20: in _resolve_config
cfg = dict(load_config()["database"])
^^^^^^^^^^^^^^^^^^^^^^^^^
E KeyError: 'database'
During handling of the above exception, another exception occurred:
tests\cross_end\test_driver_to_settlement.py:237: in test_driver_to_settlement_team_leader_flow
admin_accounting.do_freight_accounting(
tests\pages\admin\freight_accounting_page.py:149: in do_freight_accounting
raise RuntimeError(f"运费核算 SQL 重试失败!单号: {order_no}, 错误: {e}")
E RuntimeError: 运费核算 SQL 重试失败!单号: RHJC040026090100010952080133, 错误: 'database'</failure></testcase><testcase classname="cross_end.tests.test_driver_to_settlement.TestDriverToSettlement" name="test_driver_to_settlement_full_flow" time="100.261" /><testcase classname="cross_end.tests.test_driver_to_settlement.TestDriverToSettlementTeamLeader" name="test_driver_to_settlement_team_leader_flow" time="102.671"><failure message="playwright._impl._errors.TimeoutError: Page.wait_for_selector: Timeout 5000ms exceeded.&#10;Call log:&#10; - waiting for locator(&quot;table tbody tr&quot;) to be visible&#10; 14 × locator resolved to 5 elements. Proceeding with the first one: &lt;tr&gt;…&lt;/tr&gt;">tests\cross_end\tests\test_driver_to_settlement.py:239: in test_driver_to_settlement_team_leader_flow
admin_accounting.do_finance_payment(transport_order_no, verify_code="1234")
tests\cross_end\pages\admin\freight_accounting_page.py:266: in do_finance_payment
self._click_table_action(button_index=2)
tests\cross_end\pages\admin\freight_accounting_page.py:82: in _click_table_action
self.page.wait_for_selector("table tbody tr", timeout=5_000)
C:\Users\23184\AppData\Local\Programs\Python\Python312\Lib\site-packages\playwright\sync_api\_generated.py:9033: in wait_for_selector
self._sync(
C:\Users\23184\AppData\Local\Programs\Python\Python312\Lib\site-packages\playwright\_impl\_page.py:427: in wait_for_selector
return await self._main_frame.wait_for_selector(**locals_to_params(locals()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
C:\Users\23184\AppData\Local\Programs\Python\Python312\Lib\site-packages\playwright\_impl\_frame.py:394: in wait_for_selector
await self._channel.send(
C:\Users\23184\AppData\Local\Programs\Python\Python312\Lib\site-packages\playwright\_impl\_connection.py:76: in send
return await self._connection.wrap_api_call(
C:\Users\23184\AppData\Local\Programs\Python\Python312\Lib\site-packages\playwright\_impl\_connection.py:632: in wrap_api_call
raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
E playwright._impl._errors.TimeoutError: Page.wait_for_selector: Timeout 5000ms exceeded.
E Call log:
E - waiting for locator("table tbody tr") to be visible
E 14 × locator resolved to 5 elements. Proceeding with the first one: &lt;tr&gt;…&lt;/tr&gt;</failure></testcase><testcase classname="cross_end.tests.test_freight_full_flow.TestFreightFullFlow" name="test_full_freight_flow" time="41.624"><failure message="AssertionError: Locator expected to be visible&#10;Actual value: hidden &#10;Call log:&#10; - Expect &quot;to_be_visible&quot; with timeout 30000ms&#10; - waiting for get_by_text(&quot;运输管理&quot;).first&#10; 60 × locator resolved to &lt;span&gt;运输管理&lt;/span&gt;&#10; - unexpected value &quot;hidden&quot;&#10;&#10;Aria snapshot:&#10;- text: &#10;- heading &quot;系统布局配置&quot; [level=3]&#10;- text: 主题色  开启 Tags-View&#10;- switch [checked]:&#10; - checkbox [checked]&#10;- text: 固定 Header&#10;- switch:&#10; - checkbox&#10;- text: 侧边栏 Logo&#10;- switch [checked]:&#10; - checkbox [checked]&#10;- img&#10;- link:&#10; - /url: &quot;#/&quot;&#10; - img&#10;- menubar:&#10; - link &quot;首页&quot;:&#10; - /url: &quot;#/home&quot;&#10; - menuitem &quot;首页&quot;&#10; - menuitem &quot;基础信息 &quot;&#10; - menuitem &quot;整车运输 &quot;&#10; - menuitem &quot;管理服务 &quot;&#10; - menuitem &quot;同城运输 &quot;&#10; - menuitem &quot;增值服务 &quot;&#10; - menuitem &quot;财务统计 &quot;&#10; - menuitem &quot;系统管理 &quot;&#10; - link &quot;资源控制&quot;:&#10; - /url: &quot;#/resourceController&quot;&#10; - menuitem &quot;资源控制&quot;&#10;- img&#10;- navigation &quot;Breadcrumb&quot;:&#10; - link &quot;首页&quot;&#10;- textbox &quot;搜索&quot;&#10;- button &quot;超级管理员 &quot;:&#10; - text: 超级管理员&#10; - emphasis: &#10;- text: 首页 RELEASE SOURSE 发布货源 ORDER MANAGEMENT 订单管理 CUSTOMER SERVICE 客服管理&#10;- link &quot;BIG DATA CENTER 大数据中心&quot;:&#10; - /url: https://ybxcx.ynyun8.com:8000/Bigdata/&#10;- link &quot;ZHONGMIN BIG DATA 中闽大数据&quot;:&#10; - /url: https://ybxcx.ynyun8.com:8000/zm/&#10; - img&#10; - text: ZHONGMIN BIG DATA 中闽大数据&#10;- text: 运输流程 官网 货源发布 货源审核 货源管理 运输核算 运单管理 预付 财务打款&#10;- link:&#10; - /url: https://www.ynyun8.com/&#10;- text: 平台车辆 平台订单 平台车辆总计 12,832 平台车辆 153,938 平台运力(吨) 货源单总数: 9948 1763 未接单 116 已接单 1347 已结算 30 已撤销 运输单总数: 29939 10073 待运输 460 运输中 7189 已卸货 货源单类型 9519 正常单 138 内容报价单 交易数据 充值总额(元) 158,232 交易总额(元) 117,687,373 运费总额(元) 37,980,387 开票总额(元) 838,947">tests\cross_end\tests\test_freight_full_flow.py:67: in test_full_freight_flow
navbar.go_to_submenu("运输管理", "货源管理")
tests\web\admin\pages\components\navbar.py:42: in go_to_submenu
self.go_to(parent_menu)
tests\web\admin\pages\components\navbar.py:33: in go_to
self.click_when_ready(menu_item)
tests\web\admin\pages\base_page.py:53: in click_when_ready
self.wait_visible(locator)
tests\web\admin\pages\base_page.py:33: in wait_visible
expect(locator).to_be_visible(timeout=timeout_ms or self.timeout)
E AssertionError: Locator expected to be visible
E Actual value: hidden
E Call log:
E - Expect "to_be_visible" with timeout 30000ms
E - waiting for get_by_text("运输管理").first
E 60 × locator resolved to &lt;span&gt;运输管理&lt;/span&gt;
E - unexpected value "hidden"
E
E Aria snapshot:
E - text: 
E - heading "系统布局配置" [level=3]
E - text: 主题色  开启 Tags-View
E - switch [checked]:
E - checkbox [checked]
E - text: 固定 Header
E - switch:
E - checkbox
E - text: 侧边栏 Logo
E - switch [checked]:
E - checkbox [checked]
E - img
E - link:
E - /url: "#/"
E - img
E - menubar:
E - link "首页":
E - /url: "#/home"
E - menuitem "首页"
E - menuitem "基础信息 "
E - menuitem "整车运输 "
E - menuitem "管理服务 "
E - menuitem "同城运输 "
E - menuitem "增值服务 "
E - menuitem "财务统计 "
E - menuitem "系统管理 "
E - link "资源控制":
E - /url: "#/resourceController"
E - menuitem "资源控制"
E - img
E - navigation "Breadcrumb":
E - link "首页"
E - textbox "搜索"
E - button "超级管理员 ":
E - text: 超级管理员
E - emphasis: 
E - text: 首页 RELEASE SOURSE 发布货源 ORDER MANAGEMENT 订单管理 CUSTOMER SERVICE 客服管理
E - link "BIG DATA CENTER 大数据中心":
E - /url: https://ybxcx.ynyun8.com:8000/Bigdata/
E - link "ZHONGMIN BIG DATA 中闽大数据":
E - /url: https://ybxcx.ynyun8.com:8000/zm/
E - img
E - text: ZHONGMIN BIG DATA 中闽大数据
E - text: 运输流程 官网 货源发布 货源审核 货源管理 运输核算 运单管理 预付 财务打款
E - link:
E - /url: https://www.ynyun8.com/
E - text: 平台车辆 平台订单 平台车辆总计 12,832 平台车辆 153,938 平台运力(吨) 货源单总数: 9948 1763 未接单 116 已接单 1347 已结算 30 已撤销 运输单总数: 29939 10073 待运输 460 运输中 7189 已卸货 货源单类型 9519 正常单 138 内容报价单 交易数据 充值总额(元) 158,232 交易总额(元) 117,687,373 运费总额(元) 37,980,387 开票总额(元) 838,947</failure></testcase></testsuite></testsuites>