更新 playwright_automation 和 screenshots 服务
This commit is contained in:
@@ -117,18 +117,40 @@ def take_screenshot_for_account(
|
||||
else:
|
||||
bz = 2 # 应读
|
||||
target_url = f"{base}/admin/center.aspx?bz={bz}"
|
||||
automation.main_page.goto(target_url, timeout=60000)
|
||||
current_url = getattr(automation.main_page, "url", "") or ""
|
||||
if "center.aspx" not in current_url:
|
||||
raise RuntimeError(f"unexpected_url:{current_url}")
|
||||
# 目标:保留外层框架(左侧菜单/顶部栏),仅在 mainframe 内部导航到目标内容页
|
||||
iframe = None
|
||||
try:
|
||||
automation.main_page.wait_for_load_state("networkidle", timeout=30000)
|
||||
iframe = automation.get_iframe_safe(retry=True, max_retries=5)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
automation.main_page.wait_for_selector("table.ltable", timeout=20000)
|
||||
except Exception:
|
||||
pass
|
||||
iframe = None
|
||||
|
||||
if iframe:
|
||||
iframe.goto(target_url, timeout=60000)
|
||||
current_url = getattr(iframe, "url", "") or ""
|
||||
if "center.aspx" not in current_url:
|
||||
raise RuntimeError(f"unexpected_iframe_url:{current_url}")
|
||||
try:
|
||||
iframe.wait_for_load_state("networkidle", timeout=30000)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
iframe.wait_for_selector("table.ltable", timeout=20000)
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
# 兜底:若获取不到 iframe,则退回到主页面直达
|
||||
automation.main_page.goto(target_url, timeout=60000)
|
||||
current_url = getattr(automation.main_page, "url", "") or ""
|
||||
if "center.aspx" not in current_url:
|
||||
raise RuntimeError(f"unexpected_url:{current_url}")
|
||||
try:
|
||||
automation.main_page.wait_for_load_state("networkidle", timeout=30000)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
automation.main_page.wait_for_selector("table.ltable", timeout=20000)
|
||||
except Exception:
|
||||
pass
|
||||
navigated = True
|
||||
except Exception as nav_error:
|
||||
log_to_client(f"直达页面失败,将尝试按钮切换: {str(nav_error)[:120]}", user_id, account_id)
|
||||
@@ -269,4 +291,3 @@ def take_screenshot_for_account(
|
||||
)
|
||||
if not submitted:
|
||||
screenshot_callback(None, "截图队列已满,请稍后重试")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user