{"record":{"id":"29c8e279471bbcb1","repo":"xpzouying/xiaohongshu-mcp","slug":"w-29c8e2","errorCode":null,"errorMessage":"无法点击提交按钮: %w","messagePattern":"无法点击提交按钮: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/comment_feed.go","lineNumber":74,"sourceCode":"\t\treturn fmt.Errorf(\"未找到评论输入区域: %w\", err)\n\t}\n\n\tif err := humanize.Type(ctx, elem2, content); err != nil {\n\t\tlogrus.Warnf(\"Failed to input comment content: %v\", err)\n\t\treturn fmt.Errorf(\"无法输入评论内容: %w\", err)\n\t}\n\n\thumanize.Delay(ctx, humanize.AfterType)\n\n\tsubmitButton, err := page.Element(\"div.bottom button.submit\")\n\tif err != nil {\n\t\tlogrus.Warnf(\"Failed to find submit button: %v\", err)\n\t\treturn fmt.Errorf(\"未找到提交按钮: %w\", err)\n\t}\n\n\tif err := humanize.Click(submitButton); err != nil {\n\t\tlogrus.Warnf(\"Failed to click submit button: %v\", err)\n\t\treturn fmt.Errorf(\"无法点击提交按钮: %w\", err)\n\t}\n\n\thumanize.Delay(ctx, humanize.AfterClick)\n\n\t// 就地校验：提交后评论应在评论区渲染出现；未出现则判定失败，避免假成功。\n\tif !waitCommentRendered(page, content, 4*time.Second) {\n\t\tlogrus.Warnf(\"评论提交后未在评论区渲染，判定未成功: feed=%s\", feedID)\n\t\treturn fmt.Errorf(\"评论未确认成功：提交后未在评论区出现（可能账号被限制或发送失败），feed: %s\", feedID)\n\t}\n\n\tlogrus.Infof(\"Comment posted and verified to feed: %s\", feedID)\n\treturn nil\n}\n\n// commentRendered 就地读当前页评论区 DOM，判断指定文本的评论是否已渲染出现。\n// 不重新导航、不滚动——只读已加载的 .comments-container 的可见文本。\nfunc commentRendered(page *rod.Page, content string) bool {\n\tres, err := page.Eval(`(txt) => {","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/comment_feed.go#L56-L92","documentation":"PostComment 找到提交按钮后 humanize.Click 模拟点击失败：按钮被浮层遮挡、处于禁用态或页面在点击瞬间重渲染导致坐标失效。","triggerScenarios":"humanize.Click on the submit button fails because the editor re-rendered and replaced the button node, a toast/overlay covers it, or the page started navigating on Enter.","commonSituations":"Client-side validation clearing the editor right before submit; anti-bot challenge popping up; slow hydration causing stale element reference; duplicate rapid calls.","solutions":["Retry PostComment once after a delay; transient overlay/staleness often clears","Wait for page stability before submitting (no pending network/animations)","Check for and dismiss any popup/captcha before clicking","Re-verify selectors in case the button node is replaced on re-render"],"exampleFix":"// before\nerr := svc.PostComment(ctx, feedID, content) // single attempt\n// after\nif err := svc.PostComment(ctx, feedID, content); err != nil {\n    time.Sleep(3 * time.Second)\n    err = svc.PostComment(ctx, feedID, content)\n}","handlingStrategy":"retry","validationCode":"// 点击前等待无弹窗、页面稳定\npage.MustWaitStable()\n// 若可注入：确认无遮罩层元素覆盖提交按钮","typeGuard":null,"tryCatchPattern":"var err error\nfor i := 0; i < 3; i++ {\n    if err = svc.PostComment(ctx, feedID, content); err == nil || !strings.Contains(err.Error(), \"无法点击提交按钮\") {\n        break\n    }\n    time.Sleep(3 * time.Second)\n}","preventionTips":["提交前清理弹窗/验证码遮挡","页面稳定后再点击，避免元素替换导致 stale","控制调用频率避免触发风控弹窗"],"tags":["click","submit","dom","go-rod","comment"],"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"}