chore: auto release commit (2026-09-15 01:15:35)
Some checks failed
技能自动化发布 / release (push) Failing after 5s
Some checks failed
技能自动化发布 / release (push) Failing after 5s
This commit is contained in:
@@ -2,6 +2,13 @@
|
||||
|
||||
本文件对应技能市场 **「更新日志」** Tab。
|
||||
|
||||
## 1.1.24
|
||||
|
||||
- **修复 `/industries/campus/smartcampus/login` 等待过久问题**:sandbox 在用户首次登录后可能把人踢回 SPA 二级登录页(按钮中文「登录」),之前根域自动登录代码不识别这个 URL + 中文按钮,导致脚本卡死等用户输入
|
||||
- `_try_auto_sign_in` 扩展为通用版本:支持 `#jc-user` / `input[type='tel']` / `input[autocomplete='username']` 多种 user input selector;按钮文本按优先级匹配 `Sign in` > `登录` > `Login` > `signin` > `submit`
|
||||
- `collect_all` 登录后新增步骤 4.5:等 URL 稳定到 `/app/` 或 `/select` 后,若发现 URL 仍含 `/login` / `/signin`(落在 SPA 二级登录页),自动重走一次 `_try_auto_sign_in` → 再等 URL 跳到 `/app/` 或 `/select`
|
||||
- 新增 4 个测试覆盖 `_try_auto_sign_in`(SPA 中文按钮 / 根域英文按钮 / input 空 / selector 超时),合计 58/58
|
||||
|
||||
## 1.1.23
|
||||
|
||||
- **修复登录后跳 /app/home 的流程**:
|
||||
|
||||
2
SKILL.md
2
SKILL.md
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: 合同到期智能预警与续聘辅助
|
||||
description: "当用户说要扫描即将到期的合同、查 90/60/30 天预警名单、给某位教师生成续聘任务书、下发单位版续聘清单、从 SmartCampus HR 平台抓合同数据、解析续聘材料 PDF/Word、查看本月合同到期人员清单时,加载本技能。支持定时扫描(每日凌晨)+ 数据管理 + Agent 三入口,覆盖合同到期智能预警与续聘辅助全流程。"
|
||||
version: 1.1.23
|
||||
version: 1.1.24
|
||||
author: 深圳匠厂科技有限公司
|
||||
metadata:
|
||||
openclaw:
|
||||
|
||||
@@ -180,19 +180,27 @@ def _is_spa_routed(page) -> bool:
|
||||
def _try_auto_sign_in(page, wait_input_sec: int = 2) -> bool:
|
||||
"""v1.1.21:检测登录页 demo/123456 是否已预填,有则自动点 Sign in。
|
||||
|
||||
适用场景:sandbox root 登录页(https://sandbox.jc2009.com/)
|
||||
默认有 demo + 123456 预填在 #jc-user / #jc-pass,脚本无需 fill 直接点。
|
||||
v1.1.24:扩展到支持 SPA 二级登录页(/industries/campus/smartcampus/login),
|
||||
按钮文本可能是中文「登录」而非英文「Sign in」。
|
||||
|
||||
适用场景:
|
||||
- 根域登录页(https://sandbox.jc2009.com/):按钮「Sign in」
|
||||
- SPA 二级登录页(/industries/campus/smartcampus/login):按钮「登录」
|
||||
默认有 demo/123456(或 18677308191 等真实账号)预填在 input。
|
||||
|
||||
行为:
|
||||
1. 等 #jc-user 出现,最长 wait_input_sec 秒(默认 2s)
|
||||
2. 检查 #jc-user 和 #jc-pass 是否都有值
|
||||
3. 有值 → 点 Sign in → return True
|
||||
4. 无值 → return False(交给 _wait_for_manual_login 接管)
|
||||
1. 等 input 出现,最长 wait_input_sec 秒(默认 2s)
|
||||
2. 检查 input 是否都有值
|
||||
3. 有值 → 点 Sign in / 登录 → return True
|
||||
4. 无值 → return False(交给 _wait_for_login_inputs_filled 接管)
|
||||
|
||||
不会自动 fill(如果没值就放弃,让用户自己输)。
|
||||
"""
|
||||
try:
|
||||
page.wait_for_selector("#jc-user, #jc-pass", timeout=wait_input_sec * 1000)
|
||||
page.wait_for_selector(
|
||||
"#jc-user, #jc-pass, input[type='tel'], input[type='password']",
|
||||
timeout=wait_input_sec * 1000,
|
||||
)
|
||||
except Exception:
|
||||
logger.info(
|
||||
"platform_collector: %ds 内未出现登录 input,跳过自动登录",
|
||||
@@ -200,9 +208,23 @@ def _try_auto_sign_in(page, wait_input_sec: int = 2) -> bool:
|
||||
)
|
||||
return False
|
||||
|
||||
user_input = page.locator("#jc-user").first
|
||||
pass_input = page.locator("#jc-pass").first
|
||||
if user_input.count() == 0 or pass_input.count() == 0:
|
||||
# 多种 input selector 优先级
|
||||
user_input = None
|
||||
for sel in ("#jc-user", "input[type='tel']", "input[autocomplete='username']"):
|
||||
loc = page.locator(sel).first
|
||||
if loc.count() > 0:
|
||||
user_input = loc
|
||||
break
|
||||
if user_input is None:
|
||||
return False
|
||||
|
||||
pass_input = None
|
||||
for sel in ("#jc-pass", "input[type='password']", "input[autocomplete='current-password']"):
|
||||
loc = page.locator(sel).first
|
||||
if loc.count() > 0:
|
||||
pass_input = loc
|
||||
break
|
||||
if pass_input is None:
|
||||
return False
|
||||
|
||||
user_val = (user_input.input_value() or "").strip()
|
||||
@@ -216,14 +238,26 @@ def _try_auto_sign_in(page, wait_input_sec: int = 2) -> bool:
|
||||
)
|
||||
return False
|
||||
|
||||
logger.info(
|
||||
"platform_collector: 登录页已预填账号(user=%r),自动点 Sign in",
|
||||
user_val,
|
||||
)
|
||||
btn = page.locator('button[type="submit"]:has-text("Sign in")').first
|
||||
if btn.count() == 0:
|
||||
logger.warning("platform_collector: 未找到 Sign in 按钮")
|
||||
# 多种按钮文本优先级:英文 Sign in > 中文登录 > submit
|
||||
btn = None
|
||||
btn_text_used = ""
|
||||
for txt in ("Sign in", "登录", "Login", "signin"):
|
||||
loc = page.locator(f"button:has-text('{txt}')").first
|
||||
if loc.count() > 0:
|
||||
btn = loc
|
||||
btn_text_used = txt
|
||||
break
|
||||
if btn is None:
|
||||
btn = page.locator("button[type='submit']").first
|
||||
btn_text_used = "submit"
|
||||
if btn is None or btn.count() == 0:
|
||||
logger.warning("platform_collector: 未找到登录按钮")
|
||||
return False
|
||||
|
||||
logger.info(
|
||||
"platform_collector: 登录页已预填账号(user=%r),自动点 %s 按钮",
|
||||
user_val, btn_text_used,
|
||||
)
|
||||
btn.click()
|
||||
return True
|
||||
|
||||
@@ -681,6 +715,35 @@ def collect_all(
|
||||
)
|
||||
# 不强行 reload —— 让用户决定是否手工刷新
|
||||
|
||||
# 4.5. v1.1.24:sandbox 可能登录后把人踢回 SPA 二级登录页
|
||||
# (/industries/campus/smartcampus/login)。如果 URL 落在
|
||||
# 这个二级登录页,再走一次 _try_auto_sign_in(已经扩展支持
|
||||
# 中文「登录」按钮);若 SPA 登录页 input 有预填账号 → 自动点;
|
||||
# 若 input 空 → 走 _wait_for_login_inputs_filled 等用户输入。
|
||||
cur_url_after_stable = page.url.lower()
|
||||
if "/login" in cur_url_after_stable or "/signin" in cur_url_after_stable:
|
||||
logger.warning(
|
||||
"platform_collector: 登录后仍落在登录页(%s),"
|
||||
"v1.1.24 触发 SPA 二级登录兜底",
|
||||
page.url,
|
||||
)
|
||||
spa_auto = _try_auto_sign_in(page, wait_input_sec=2)
|
||||
if spa_auto:
|
||||
logger.info(
|
||||
"platform_collector: ✅ SPA 二级登录页已自动登录,"
|
||||
"等 URL 跳到 /app/ 或 /select"
|
||||
)
|
||||
_wait_for_url_stable(page, ("/app/", "/select"), max_wait_sec=30)
|
||||
elif not headless:
|
||||
if _wait_for_login_inputs_filled(page, wait_sec=human_wait_timeout):
|
||||
_wait_for_url_stable(page, ("/app/", "/select"), max_wait_sec=30)
|
||||
else:
|
||||
_wait_for_manual_login(page, wait_sec=human_wait_timeout)
|
||||
else:
|
||||
raise LoginTimeoutError(
|
||||
f"SPA 二级登录页 input 空且 headless 无法手工登录(URL={page.url})"
|
||||
)
|
||||
|
||||
# 5. v1.1.22:显式跳到 SPA_HOME_URL(/app/home),等侧边栏 link 出现
|
||||
# 避免 sandbox 在 /select 中间页时直接找 sidebar link 找不到
|
||||
if "/app/home" not in page.url.lower():
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"""
|
||||
|
||||
SKILL_SLUG = "alert-contract-expiring-hr"
|
||||
SKILL_VERSION = "1.1.23"
|
||||
SKILL_VERSION = "1.1.24"
|
||||
LOG_LOGGER_NAME = "openclaw.skill.alert_contract_expiring_hr"
|
||||
PLATFORM_KIT_MIN_VERSION = "1.2.11"
|
||||
|
||||
|
||||
@@ -1366,6 +1366,180 @@ def test_wait_for_manual_login_no_goto() -> tuple[bool, str]:
|
||||
pc.URL_STABLE_REQUIRED_S = orig_stable
|
||||
|
||||
|
||||
# ---------- v1.1.24: _try_auto_sign_in SPA 二级登录页(中文「登录」按钮)----------
|
||||
|
||||
|
||||
class _FakeLocator:
|
||||
"""v1.1.24 _try_auto_sign_in 测试用的简易 Playwright Locator mock。
|
||||
|
||||
支持的 API:
|
||||
- .count() -> int
|
||||
- .input_value() -> str
|
||||
- .click() -> None
|
||||
- .first -> 自身
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
count: int = 0,
|
||||
value: str = "",
|
||||
click_log: list | None = None,
|
||||
) -> None:
|
||||
self._count = count
|
||||
self._value = value
|
||||
self._click_log = click_log if click_log is not None else []
|
||||
|
||||
@property
|
||||
def first(self) -> "_FakeLocator":
|
||||
return self
|
||||
|
||||
def count(self) -> int:
|
||||
return self._count
|
||||
|
||||
def input_value(self) -> str:
|
||||
return self._value
|
||||
|
||||
def click(self) -> None:
|
||||
self._click_log.append(self._value or "clicked")
|
||||
|
||||
|
||||
class _FakeLocatorRouter:
|
||||
"""根据 selector 返回对应 _FakeLocator 的路由器。
|
||||
|
||||
selectors: dict[selector_str, _FakeLocator]
|
||||
"""
|
||||
|
||||
def __init__(self, selectors: dict[str, _FakeLocator], page) -> None:
|
||||
self._selectors = selectors
|
||||
self._page = page
|
||||
|
||||
def __getattr__(self, sel: str):
|
||||
# loc.page 已存在则按 selector 路由
|
||||
if sel in self._selectors:
|
||||
return self._selectors[sel]
|
||||
# fallback:未注册的 selector 都返回空 locator
|
||||
return _FakeLocator(count=0)
|
||||
|
||||
|
||||
class _FakePlaywrightPage:
|
||||
"""v1.1.24 _try_auto_sign_in 测试用的 page mock。
|
||||
|
||||
usage:
|
||||
page = _FakePlaywrightPage(
|
||||
url="https://sandbox.jc2009.com/industries/campus/smartcampus/login",
|
||||
selectors={
|
||||
"input[type='tel']": _FakeLocator(count=1, value="18677308191"),
|
||||
"input[type='password']": _FakeLocator(count=1, value="***"),
|
||||
"button:has-text('登录')": _FakeLocator(count=1, click_log=click_log),
|
||||
},
|
||||
wait_for_selector_log=wait_log,
|
||||
)
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
url: str = "about:blank",
|
||||
selectors: dict[str, _FakeLocator] | None = None,
|
||||
wait_for_selector_log: list | None = None,
|
||||
wait_selector_should_raise: bool = False,
|
||||
) -> None:
|
||||
self.url = url
|
||||
self._selectors = selectors or {}
|
||||
self._wait_log = wait_for_selector_log if wait_for_selector_log is not None else []
|
||||
self._wait_should_raise = wait_selector_should_raise
|
||||
|
||||
def wait_for_selector(self, selector: str, timeout: int = 0) -> None:
|
||||
self._wait_log.append(selector)
|
||||
if self._wait_should_raise:
|
||||
raise Exception("fake: timeout")
|
||||
|
||||
@property
|
||||
def locator(self):
|
||||
return _FakeLocatorRouter(self._selectors, self)
|
||||
|
||||
|
||||
def test_try_auto_sign_in_spa_login_chinese_button() -> tuple[bool, str]:
|
||||
"""v1.1.24:SPA 二级登录页(/industries/campus/smartcampus/login),
|
||||
input 用 `input[type='tel']` / `input[type='password']`,
|
||||
按钮中文「登录」。预填有值 → 自动点登录。
|
||||
"""
|
||||
from service.platform_collector import _try_auto_sign_in
|
||||
|
||||
click_log: list[str] = []
|
||||
page = _FakePlaywrightPage(
|
||||
url="https://sandbox.jc2009.com/industries/campus/smartcampus/login",
|
||||
selectors={
|
||||
"input[type='tel']": _FakeLocator(count=1, value="18677308191"),
|
||||
"input[type='password']": _FakeLocator(count=1, value="dummy"),
|
||||
"button:has-text('登录')": _FakeLocator(count=1, click_log=click_log),
|
||||
},
|
||||
)
|
||||
if not _try_auto_sign_in(page, wait_input_sec=2):
|
||||
return False, "SPA 二级登录页预填应自动点 登录"
|
||||
if not click_log:
|
||||
return False, f"未触发点击: {click_log}"
|
||||
return True, f"SPA 二级登录页中文按钮自动点 OK(click_log={click_log})"
|
||||
|
||||
|
||||
def test_try_auto_sign_in_root_sign_in_english_button() -> tuple[bool, str]:
|
||||
"""v1.1.24(向后兼容):根域登录页(https://sandbox.jc2009.com/),
|
||||
input 用 `#jc-user` / `#jc-pass`,按钮英文「Sign in」。预填有值 → 自动点。
|
||||
"""
|
||||
from service.platform_collector import _try_auto_sign_in
|
||||
|
||||
click_log: list[str] = []
|
||||
page = _FakePlaywrightPage(
|
||||
url="https://sandbox.jc2009.com/",
|
||||
selectors={
|
||||
"#jc-user": _FakeLocator(count=1, value="demo"),
|
||||
"#jc-pass": _FakeLocator(count=1, value="123456"),
|
||||
"button:has-text('Sign in')": _FakeLocator(count=1, click_log=click_log),
|
||||
},
|
||||
)
|
||||
if not _try_auto_sign_in(page, wait_input_sec=2):
|
||||
return False, "根域登录页预填应自动点 Sign in"
|
||||
if not click_log:
|
||||
return False, f"未触发点击: {click_log}"
|
||||
return True, f"根域登录页 Sign in 自动点 OK(click_log={click_log})"
|
||||
|
||||
|
||||
def test_try_auto_sign_in_no_input_returns_false() -> tuple[bool, str]:
|
||||
"""v1.1.24:input 为空(用户还没输入)→ 返回 False,不点按钮。"""
|
||||
from service.platform_collector import _try_auto_sign_in
|
||||
|
||||
click_log: list[str] = []
|
||||
page = _FakePlaywrightPage(
|
||||
url="https://sandbox.jc2009.com/industries/campus/smartcampus/login",
|
||||
selectors={
|
||||
"input[type='tel']": _FakeLocator(count=1, value=""), # 空
|
||||
"input[type='password']": _FakeLocator(count=1, value="123"),
|
||||
"button:has-text('登录')": _FakeLocator(count=1, click_log=click_log),
|
||||
},
|
||||
)
|
||||
if _try_auto_sign_in(page, wait_input_sec=2):
|
||||
return False, "user 空时不应自动点"
|
||||
if click_log:
|
||||
return False, f"未填完不应点击: {click_log}"
|
||||
return True, "input 空返回 False 不点 OK"
|
||||
|
||||
|
||||
def test_try_auto_sign_in_selector_timeout_returns_false() -> tuple[bool, str]:
|
||||
"""v1.1.24:等 input 超时(如 URL 已是 SPA home,无登录 input)→ 返回 False。"""
|
||||
from service.platform_collector import _try_auto_sign_in
|
||||
|
||||
click_log: list[str] = []
|
||||
page = _FakePlaywrightPage(
|
||||
url="https://sandbox.jc2009.com/industries/campus/smartcampus/app/home",
|
||||
selectors={}, # 没有任何 input
|
||||
wait_selector_should_raise=True,
|
||||
)
|
||||
if _try_auto_sign_in(page, wait_input_sec=1):
|
||||
return False, "无登录 input 应返回 False"
|
||||
if click_log:
|
||||
return False, f"无 input 不应点击: {click_log}"
|
||||
return True, "无登录 input 超时返回 False OK"
|
||||
|
||||
|
||||
# ---------- v1.1.18: show-config / logs-list ----------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user