{"record":{"id":"57c419beeae40826","repo":"xpzouying/xiaohongshu-mcp","slug":"error-57c419","errorCode":null,"errorMessage":"点击可见范围下拉框失败","messagePattern":"点击可见范围下拉框失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":893,"sourceCode":"// setVisibility 设置可见范围\n// 支持: \"公开可见\"(默认), \"仅自己可见\", \"仅互关好友可见\"\nfunc setVisibility(page *rod.Page, visibility string) error {\n\tif visibility == \"\" || visibility == \"公开可见\" {\n\t\tslog.Info(\"可见范围使用默认：公开可见\")\n\t\treturn nil\n\t}\n\n\tsupported := map[string]bool{\"仅自己可见\": true, \"仅互关好友可见\": true}\n\tif !supported[visibility] {\n\t\treturn errors.Errorf(\"不支持的可见范围: %s，支持: 公开可见、仅自己可见、仅互关好友可见\", visibility)\n\t}\n\n\tdropdown, err := page.Element(\"div.permission-card-wrapper div.d-select-content\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"查找可见范围下拉框失败\")\n\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)","sourceCodeStart":875,"sourceCodeEnd":911,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L875-L911","documentation":"setVisibility wraps failure from humanize.Click on the visibility dropdown element. The dropdown was found but the click action failed, so the options popup never opens. Typically a stale-element or overlay-interception problem.","triggerScenarios":"The d-select-content element was re-rendered between Element() and Click; another overlay (cookie banner, modal) intercepts the click; CDP click timed out on a slow browser.","commonSituations":"Animations re-rendering the select right at click time; heavy page load starving the browser; remote browser with high CDP latency.","solutions":["Call dropdown.WaitStable(200ms) before humanize.Click.","Dismiss any overlapping overlays before setting visibility.","Re-locate the dropdown and retry the click once.","Increase rod CDP timeouts."],"exampleFix":"// before\nif err := humanize.Click(dropdown); err != nil {\n    return errors.Wrap(err, \"点击可见范围下拉框失败\")\n}\n// after\nif err := dropdown.WaitStable(300 * time.Millisecond); err != nil {\n    return errors.Wrap(err, \"下拉框未稳定\")\n}\nif err := humanize.Click(dropdown); err != nil {\n    return errors.Wrap(err, \"点击可见范围下拉框失败\")\n}","handlingStrategy":"retry","validationCode":"if err := dropdown.WaitStable(300 * time.Millisecond); err != nil { return errors.Wrap(err, \"下拉框未稳定\") }","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 elements before clicking","Dismiss overlays/popups before interacting","Increase CDP timeouts on slow browsers"],"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"}