fix: 兼容非滚动图片颜色采购选择 (#178)

This commit is contained in:
chengma
2026-08-12 10:48:36 +08:00
parent 69b3200665
commit cd9c552a77
4 changed files with 287 additions and 3 deletions
+28 -2
View File
@@ -49,7 +49,11 @@ from .pdd_purchase_adapter import (
PurchasePageState,
)
from .util.get_size_panle_coord import get_size_panel_coord
from .util.select_color_size import select_color, select_size
from .util.select_color_size import (
color_selection_failure_reason,
select_color,
select_size,
)
Bounds = tuple[int, int, int, int]
@@ -734,10 +738,32 @@ class U2PddPurchaseAdapter(PddPurchaseAdapter):
device, panel_xml, color, action_delay=0.2
)
if not color_selected:
failed_xml = self._dump_hierarchy()
failure_reason = color_selection_failure_reason(
failed_xml, color
)
diagnostics: dict[str, Any] = {
"selection_failure": failure_reason,
}
artifact = self._save_last_xml(
"purchase-color-selection-mismatch"
)
if artifact is not None:
diagnostics["artifacts"] = [artifact]
messages = {
"target_not_visible": f"没有找到目标颜色:{color}",
"safe_target_missing": (
f"目标颜色没有完整可见的安全点击位置:{color}"
),
"selection_unconfirmed": (
f"点击颜色后页面没有确认已选中:{color}"
),
}
raise PddPurchaseError(
"PURCHASE_OPTIONS_MISMATCH",
f"没有精确选中颜色:{color}",
messages[failure_reason],
step="purchase_select_options",
diagnostics=diagnostics,
)
size = checked.get("size")
if size: