{"record":{"id":"0baefd67cffc39eb","repo":"xpzouying/xiaohongshu-mcp","slug":"error-0baefd","errorCode":null,"errorMessage":"选择可见范围失败","messagePattern":"选择可见范围失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":909,"sourceCode":"\t}\n\tif err := humanize.Click(dropdown); err != nil {\n\t\treturn errors.Wrap(err, \"点击可见范围下拉框失败\")\n\t}\n\ttime.Sleep(500 * time.Millisecond)\n\n\t// 在弹窗中查找并点击目标选项\n\topts, err := page.Elements(\"div.d-options-wrapper div.d-grid-item div.custom-option\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"查找可见范围选项失败\")\n\t}\n\tfor _, opt := range opts {\n\t\ttext, err := opt.Text()\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif strings.Contains(text, visibility) {\n\t\t\tif err := humanize.Click(opt); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"选择可见范围失败\")\n\t\t\t}\n\t\t\tslog.Info(\"已设置可见范围\", \"visibility\", visibility)\n\t\t\ttime.Sleep(200 * time.Millisecond)\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn errors.Errorf(\"未找到可见范围选项: %s\", visibility)\n}\n\n// setSchedulePublish 设置定时发布时间\nfunc setSchedulePublish(ctx context.Context, page *rod.Page, t time.Time) error {\n\t// 1. 点击定时发布开关\n\tif err := clickScheduleSwitch(page); err != nil {\n\t\treturn err\n\t}\n\ttime.Sleep(800 * time.Millisecond)\n\n\t// 2. 设置日期时间","sourceCodeStart":891,"sourceCodeEnd":927,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L891-L927","documentation":"setVisibility wraps failure from humanize.Click on the matched visibility option item. The option containing the requested visibility text was found but clicking it failed, so the setting was not applied. Stale element or click interception are the usual causes.","triggerScenarios":"Option item re-rendered between the Text() read and the Click; popup closed before the click; overlay intercepts pointer events; CDP click timeout.","commonSituations":"Popup auto-closes due to focus loss on slow environments; animations re-rendering option nodes; concurrent automation clicking elsewhere.","solutions":["Call opt.WaitStable before humanize.Click.","Re-query the options and retry the click once.","Increase the wait after opening the dropdown so the popup is fully interactive.","Check for overlays that could swallow the click."],"exampleFix":"// before\nif err := humanize.Click(opt); err != nil {\n    return errors.Wrap(err, \"选择可见范围失败\")\n}\n// after\n_ = opt.WaitStable(200 * time.Millisecond)\nif err := humanize.Click(opt); err != nil {\n    return errors.Wrap(err, \"选择可见范围失败\")\n}","handlingStrategy":"retry","validationCode":"if err := opt.WaitStable(200 * time.Millisecond); err != nil { continue } // 跳过不稳定项","typeGuard":"func clickable(e *rod.Element) bool { return e != nil && e.WaitStable(200*time.Millisecond) == nil }","tryCatchPattern":"if err := setVisibility(page, v); err != nil {\n    if strings.Contains(err.Error(), \"选择可见范围失败\") {\n        time.Sleep(1 * time.Second)\n        return setVisibility(page, v)\n    }\n    return err\n}","preventionTips":["Stabilize option elements before clicking","Re-query options instead of reusing stale nodes","Keep the dropdown popup focused during selection"],"tags":["browser-automation","rod","click-failed"],"backgroundTag":"cdp-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"}