{"record":{"id":"7989765ce40f5579","repo":"xpzouying/xiaohongshu-mcp","slug":"error-798976","errorCode":null,"errorMessage":"点击原创声明开关失败","messagePattern":"点击原创声明开关失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":1017,"sourceCode":"\t\t}\n\n\t\t// 检查开关是否已打开\n\t\tchecked, err := switchElem.Eval(`() => {\n\t\t\tconst input = this.querySelector('input[type=\"checkbox\"]');\n\t\t\treturn input ? input.checked : false;\n\t\t}`)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tif checked.Value.Bool() {\n\t\t\tslog.Info(\"原创声明已开启\")\n\t\t\treturn nil\n\t\t}\n\n\t\t// 点击开关\n\t\tif err := humanize.Click(switchElem); err != nil {\n\t\t\treturn errors.Wrap(err, \"点击原创声明开关失败\")\n\t\t}\n\n\t\ttime.Sleep(500 * time.Millisecond)\n\n\t\t// 处理原创声明确认弹窗\n\t\tif err := confirmOriginalDeclaration(page); err != nil {\n\t\t\treturn errors.Wrap(err, \"确认原创声明失败\")\n\t\t}\n\n\t\tslog.Info(\"已开启原创声明\")\n\t\treturn nil\n\t}\n\n\treturn errors.New(\"未找到原创声明选项\")\n}\n\n// confirmOriginalDeclaration 交互（勾选须知、点声明按钮）走 go-rod 点击；\n// 仅用只读 Eval 读取 checkbox 勾选态（不产生交互，无法用属性判断的自定义组件才用）。","sourceCodeStart":999,"sourceCodeEnd":1035,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L999-L1035","documentation":"Thrown by setOriginal when the original-declaration d-switch was located but humanize.Click on it failed. The element existed but the simulated click could not complete — typically invisibility, pointer interception by an overlay, or a stale/re-rendered node.","triggerScenarios":"The switch is offscreen until scrolled into view; a tooltip on the span.has-tips intercepts the click; the card re-renders between lookup and click; page closed mid-click.","commonSituations":"Headless viewport too small so the card is offscreen; hover tooltips overlapping the switch; slow renders producing stale element handles.","solutions":["Scroll the card/switch into view before clicking.","Re-query the switch element immediately before the click.","Move the mouse away / dismiss any tooltip overlays before clicking.","Retry the click once after a short wait."],"exampleFix":"// before\nif err := humanize.Click(switchElem); err != nil {\n\treturn errors.Wrap(err, \"点击原创声明开关失败\")\n}\n// after\nswitchElem.MustScrollIntoView()\ntime.Sleep(200 * time.Millisecond)\nswitchElem, err = card.Element(\"div.d-switch\")\nif err != nil {\n\treturn errors.Wrap(err, \"点击原创声明开关失败\")\n}\nif err := humanize.Click(switchElem); err != nil {\n\treturn errors.Wrap(err, \"点击原创声明开关失败\")\n}","handlingStrategy":"retry","validationCode":"ok, err := page.Eval(`() => { const cards=[...document.querySelectorAll('div.custom-switch-card')]; const c=cards.find(x=>x.innerText.includes('原创声明')); if(!c) return false; const s=c.querySelector('div.d-switch'); return !!s && s.offsetParent !== null; }`)\nif err != nil || !ok.Value.Bool() {\n\treturn fmt.Errorf(\"原创声明开关不可点击\")\n}","typeGuard":null,"tryCatchPattern":"if err := setOriginal(page); err != nil {\n\tif strings.Contains(err.Error(), \"点击原创声明开关失败\") {\n\t\ttime.Sleep(1 * time.Second)\n\t\treturn setOriginal(page)\n\t}\n\treturn err\n}","preventionTips":["ScrollIntoView cards before clicking in small headless viewports.","Re-query the switch immediately before the click.","Check the switch state via read-only Eval before clicking; skip if already on.","Avoid hovering tooltips before clicking the switch."],"tags":["click-failed","go-rod","stale-element","automation"],"backgroundTag":"element-click-failed","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}