From 430274dbf922ab4a1d0168dfdbcc4835f5f461a4 Mon Sep 17 00:00:00 2001 From: taojianmin Date: Tue, 15 Sep 2026 01:23:04 +0800 Subject: [PATCH] chore: auto release commit (2026-09-15 01:23:04) --- CHANGELOG.md | 7 ++++ SKILL.md | 2 +- scripts/service/platform_collector.py | 52 ++++++++++++++++++++------- scripts/util/constants.py | 2 +- tests/run_tests.py | 47 ++++++++++-------------- 5 files changed, 67 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2ed72e..96ddc4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ 本文件对应技能市场 **「更新日志」** Tab。 +## 1.1.26 + +- **按用户最新要求改回「自动点登录」行为**:「到了 /industries/campus/smartcampus/login 整个页面,有账号和密码可用直接点登录跳转」 +- `_wait_for_login_inputs_filled` 改回 v1.1.21 行为:input 都有值 → 自动点 Sign in / 登录按钮 → return True +- 与 `_try_auto_sign_in` 行为统一:登录页 = 「有数据自动点」/ 「无数据等用户输入」 +- 测试替换:`wait_login_inputs_filled_no_auto_click_v1_24` → `wait_login_inputs_filled_auto_click_v1_26`,合计 63/63 + ## 1.1.25 - **按用户要求修正登录页等待逻辑**: diff --git a/SKILL.md b/SKILL.md index d7f3200..483d6a6 100644 --- a/SKILL.md +++ b/SKILL.md @@ -1,7 +1,7 @@ --- name: 合同到期智能预警与续聘辅助 description: "当用户说要扫描即将到期的合同、查 90/60/30 天预警名单、给某位教师生成续聘任务书、下发单位版续聘清单、从 SmartCampus HR 平台抓合同数据、解析续聘材料 PDF/Word、查看本月合同到期人员清单时,加载本技能。支持定时扫描(每日凌晨)+ 数据管理 + Agent 三入口,覆盖合同到期智能预警与续聘辅助全流程。" -version: 1.1.25 +version: 1.1.26 author: 深圳匠厂科技有限公司 metadata: openclaw: diff --git a/scripts/service/platform_collector.py b/scripts/service/platform_collector.py index fda2199..bbbf6b8 100644 --- a/scripts/service/platform_collector.py +++ b/scripts/service/platform_collector.py @@ -263,14 +263,17 @@ def _try_auto_sign_in(page, wait_input_sec: int = 2) -> bool: def _wait_for_login_inputs_filled(page, wait_sec: int = HUMAN_WAIT_TIMEOUT) -> bool: - """v1.1.21:等用户输入完账号密码。 - v1.1.24:**不再自动点 Sign in**——按用户要求:「等待用户输入信息后跳转页面」, - 按钮交给用户自己点。脚本只负责等 URL 跳离登录页。 + """v1.1.21:等用户输入完账号密码,然后自动点登录按钮。 - - 每 HUMAN_POLL_INTERVAL 秒检查 #jc-user / #jc-pass 是否有值(仅做状态日志) - - URL 已离开登录页 → return True(用户可能自己点登录完成) - - input 有值 → 提示「请点登录按钮」(**脚本不抢按钮**) - - 超时未跳离登录页 → return False + v1.1.26:按用户最新要求改回**自动点登录**行为—— + 「到了 /industries/campus/smartcampus/login 整个页面,有账号和密码可用直接点登录跳转」, + 不再等用户自己点。 + + 优先级(任一 selector 命中即视为有 input): + - user: `#jc-user` / `input[type='tel']` / `input[autocomplete='username']` + - pass: `#jc-pass` / `input[type='password']` / `input[autocomplete='current-password']` + + 按钮文本优先级:`Sign in` / `登录` / `Login` / `signin` / `submit`。 """ deadline = time.monotonic() + wait_sec last_prompt_at = time.monotonic() @@ -286,21 +289,21 @@ def _wait_for_login_inputs_filled(page, wait_sec: int = HUMAN_WAIT_TIMEOUT) -> b ) return True - # 探测 input 是否就绪 + 是否已有值(仅做日志,不主动 click) + # 探测 input(多 selector 优先级) + user_val, pass_val = "", "" + user_loc, pass_loc = None, None for sel in ("#jc-user", "input[type='tel']", "input[autocomplete='username']"): loc = page.locator(sel).first if loc.count() > 0: + user_loc = loc user_val = (loc.input_value() or "").strip() break - else: - user_val = "" for sel in ("#jc-pass", "input[type='password']", "input[autocomplete='current-password']"): loc = page.locator(sel).first if loc.count() > 0: + pass_loc = loc pass_val = (loc.input_value() or "").strip() break - else: - pass_val = "" now = time.monotonic() if now - last_state_log >= HUMAN_PROMPT_INTERVAL: @@ -310,11 +313,34 @@ def _wait_for_login_inputs_filled(page, wait_sec: int = HUMAN_WAIT_TIMEOUT) -> b bool(user_val), bool(pass_val), cur_url, ) - # 提醒用户:input 有值时明确告诉用户「点登录按钮」 + # input 都有值 → 自动点登录按钮(v1.1.26 关键:用户最新要求自动点) + if user_val and pass_val: + 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 not None and btn.count() > 0: + logger.info( + "platform_collector: ✅ 账号密码已填好(user=%r),自动点 %s 按钮", + user_val, btn_text_used, + ) + btn.click() + return True + logger.warning("platform_collector: input 有值但找不到登录按钮") + + # 提醒用户 if now - last_prompt_at >= HUMAN_PROMPT_INTERVAL: last_prompt_at = now remaining = int(deadline - now) if user_val and pass_val: + # 上面 click 应该已经 return,不会到这里 print( f"[登录] ✅ 账号密码已填好(user={user_val[:3]}***)," f"请点「登录」按钮,剩余 {remaining}s..." diff --git a/scripts/util/constants.py b/scripts/util/constants.py index c418cbb..4ebadce 100644 --- a/scripts/util/constants.py +++ b/scripts/util/constants.py @@ -6,7 +6,7 @@ """ SKILL_SLUG = "alert-contract-expiring-hr" -SKILL_VERSION = "1.1.25" +SKILL_VERSION = "1.1.26" LOG_LOGGER_NAME = "openclaw.skill.alert_contract_expiring_hr" PLATFORM_KIT_MIN_VERSION = "1.2.11" diff --git a/tests/run_tests.py b/tests/run_tests.py index cb23fdd..cecbb16 100644 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -1552,46 +1552,37 @@ def test_try_auto_sign_in_selector_timeout_returns_false() -> tuple[bool, str]: return True, "无登录 input 超时返回 False OK" -def test_wait_for_login_inputs_filled_no_auto_click_v1_24() -> tuple[bool, str]: - """v1.1.24:`_wait_for_login_inputs_filled` **不再自动点登录按钮**—— - 用户输入完成(input 有值)后等 URL 跳离登录页,**按钮交给用户自己点**。 - """ - import threading - import time as _time +def test_wait_for_login_inputs_filled_auto_click_v1_26() -> tuple[bool, str]: + """v1.1.26:`_wait_for_login_inputs_filled` **自动点登录按钮**—— + 按用户最新要求:「到了 /industries/campus/smartcampus/login 整个页面, + 有账号和密码可用直接点登录跳转」。 + input 有值时点击 `button:has-text('登录')` 或 `Sign in`(多按钮文本优先级)。 + """ from service import platform_collector as pc - # 缩短轮询周期:HUMAN_POLL_INTERVAL 默认 5s,太长测试慢 orig_poll = pc.HUMAN_POLL_INTERVAL orig_prompt = pc.HUMAN_PROMPT_INTERVAL pc.HUMAN_POLL_INTERVAL = 0.2 pc.HUMAN_PROMPT_INTERVAL = 0.2 try: - page = _FakePage( - "https://sandbox.jc2009.com/industries/campus/smartcampus/login", + 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), + }, ) - # 0.6s 后 URL 跳到 /app/(模拟用户点登录按钮后跳转) - def fake_user_jump(): - _time.sleep(0.6) - page.url = "https://sandbox.jc2009.com/industries/campus/smartcampus/app/home" - - threading.Thread(target=fake_user_jump, daemon=True).start() - result = pc._wait_for_login_inputs_filled(page, wait_sec=5) if not result: - return False, "URL 已跳到 /app/ 应返回 True" + return False, "input 有值应自动点登录 → return True" - if page.goto_calls: - return False, f"等待期间不应 goto: {page.goto_calls}" - if page.reload_calls: - return False, f"等待期间不应 reload: {page.reload_calls}" - if page.click_calls: - return False, ( - f"v1.1.24 修复:等用户输入期间**不应自动点登录**按钮," - f"但 click_calls={page.click_calls}" - ) - return True, "v1.1.24 等用户跳离登录页(不抢按钮)OK" + if not click_log: + return False, f"v1.1.26 应自动点登录按钮,但 click_log={click_log}" + return True, f"v1.1.26 自动点登录按钮 OK(click_log={click_log})" finally: pc.HUMAN_POLL_INTERVAL = orig_poll pc.HUMAN_PROMPT_INTERVAL = orig_prompt @@ -1874,7 +1865,7 @@ def main() -> int: _run("login_flow/auto_sign_in_root_english_button", test_try_auto_sign_in_root_sign_in_english_button) _run("login_flow/auto_sign_in_no_input_returns_false", test_try_auto_sign_in_no_input_returns_false) _run("login_flow/auto_sign_in_selector_timeout_returns_false", test_try_auto_sign_in_selector_timeout_returns_false) - _run("login_flow/wait_login_inputs_filled_no_auto_click_v1_24", test_wait_for_login_inputs_filled_no_auto_click_v1_24) + _run("login_flow/wait_login_inputs_filled_auto_click_v1_26", test_wait_for_login_inputs_filled_auto_click_v1_26) _run("show_config/masks_tokens", test_show_config_masks_tokens) _run("show_config/skips_empty", test_show_config_skips_empty) _run("show_config/skips_comments", test_show_config_skips_comments)