|
|
@@ -105,6 +105,21 @@ class TlsPlugin2(IVSPlg):
|
|
|
self._log(f"Session expired.")
|
|
|
return False
|
|
|
return True
|
|
|
+
|
|
|
+ def _save_screenshot(self, name_prefix):
|
|
|
+ try:
|
|
|
+ timestamp = int(time.time())
|
|
|
+ filename = f"{self.instance_id}_{name_prefix}_{timestamp}.jpg"
|
|
|
+ save_path = os.path.join("data", filename)
|
|
|
+ os.makedirs("data", exist_ok=True)
|
|
|
+
|
|
|
+ # [修改] 改为 full_page=False,防止页面结构异常导致截图失败
|
|
|
+ # 这样能截取到浏览器当前可视区域,最适合调试“卡住”的情况
|
|
|
+ self.page.get_screenshot(path=save_path, full_page=False)
|
|
|
+
|
|
|
+ self._log(f"Screenshot saved to {save_path}")
|
|
|
+ except Exception as e:
|
|
|
+ self._log(f"Failed to save screenshot: {e}")
|
|
|
|
|
|
def create_session(self):
|
|
|
"""
|
|
|
@@ -202,6 +217,7 @@ class TlsPlugin2(IVSPlg):
|
|
|
self._log("Reloading Login Page...")
|
|
|
self.page.get(full_login_url)
|
|
|
if not self.page.wait.ele_displayed('#email-input-field', timeout=15):
|
|
|
+ self._save_screenshot("login_load_fail")
|
|
|
raise BizLogicError("Login form not loaded")
|
|
|
|
|
|
# --- JS 注入登录 ---
|
|
|
@@ -244,6 +260,7 @@ class TlsPlugin2(IVSPlg):
|
|
|
if "login-actions" in self.page.url or "auth" in self.page.url:
|
|
|
err = "Unknown Login Error"
|
|
|
if "Invalid username" in self.page.html: err = "Invalid Credentials"
|
|
|
+ self._save_screenshot("login_submit_fail")
|
|
|
raise BizLogicError(f"Login Failed: {err}")
|
|
|
|
|
|
# --- 提取 Dashboard 信息 ---
|
|
|
@@ -262,6 +279,7 @@ class TlsPlugin2(IVSPlg):
|
|
|
break
|
|
|
|
|
|
if not self.travel_group:
|
|
|
+ self._save_screenshot("group_not_found")
|
|
|
raise NotFoundError(f"Group not found for {target_city}")
|
|
|
|
|
|
self.session_create_time = time.time()
|