{"record":{"id":"86d9d54b84c794c2","repo":"xpzouying/xiaohongshu-mcp","slug":"w-86d9d5","errorCode":null,"errorMessage":"无法点击点赞: %w","messagePattern":"无法点击点赞: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/notification_like.go","lineNumber":72,"sourceCode":"\n\titems, err := page.Elements(`.tabs-content-container > .container`)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"未找到通知条目: %w\", err)\n\t}\n\tif index >= len(items) {\n\t\treturn nil, fmt.Errorf(\"通知条目渲染数(%d)少于目标位置(%d)，页面可能未加载完\", len(items), index)\n\t}\n\n\thumanize.Delay(ctx, humanize.Reading)\n\n\tbtn, err := items[index].Element(`.action-like .like-wrapper`)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"该通知没有点赞入口（评论可能已删除或不可点赞）: %w\", err)\n\t}\n\n\thumanize.Delay(ctx, humanize.BeforeClick)\n\tif err := humanize.Click(btn); err != nil {\n\t\treturn nil, fmt.Errorf(\"无法点击点赞: %w\", err)\n\t}\n\n\tif err := n.waitLikeSettled(page, commentID, want); err != nil {\n\t\treturn nil, err\n\t}\n\n\thumanize.Delay(ctx, humanize.AfterInteract)\n\n\tlogrus.Infof(\"通知点赞成功: comment=%s liked=%v\", commentID, want)\n\treturn result, nil\n}\n\n// waitLikeSettled 等待点赞状态变成目标值；判不出来直接报错，不自动重试。\nfunc (n *NotificationAction) waitLikeSettled(page *rod.Page, commentID string, want bool) error {\n\tif n.likedMatches(page, commentID, want, likeSettleTimeout) {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"点赞未确认成功：%s 内状态未变成 %v。点赞可能已生效但同步慢，\"+","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/notification_like.go#L54-L90","documentation":"Like 找到点赞按钮后 humanize.Click 点击失败：按钮被遮挡、条目重渲染或鼠标事件被拦截，点赞动作没有送达页面。","triggerScenarios":"Like 中对 btn 调用 humanize.Click 出错：页面在 BeforeClick 延迟期间发生重渲染，按钮被替换；元素滚出视口；页面被弹层遮挡。","commonSituations":"列表在延迟期间刷新导致元素失效；动画未完成元素不可点；页面弹出登录/验证弹层。","solutions":["重试整个 Like 操作（重新定位元素后再点）","点击前检查弹层并关闭遮挡元素","减小/调整 BeforeClick 延迟，或点击前重新获取元素引用","若频繁失败，检查页面是否触发风控验证"],"exampleFix":"// before\nif err := humanize.Click(btn); err != nil { return nil, fmt.Errorf(\"无法点击点赞: %w\", err) }\n// after\nif err := humanize.Click(btn); err != nil {\n    btn, err = items[index].Element(`.action-like .like-wrapper`) // 重新获取\n    if err == nil { err = humanize.Click(btn) }\n    if err != nil { return nil, fmt.Errorf(\"无法点击点赞: %w\", err) }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"_, err := n.Like(ctx, commentID, false)\nif err != nil && strings.Contains(err.Error(), \"无法点击点赞\") {\n    time.Sleep(time.Second) // 等渲染稳定后重试\n    _, err = n.Like(ctx, commentID, false)\n}","preventionTips":["点击前关闭可能遮挡的弹层","保持拟人化延迟适中，避免延迟期间页面重渲染","频繁失败时检查是否触发风控验证","重试时重新获取元素引用而非复用旧节点"],"tags":["go","rod","click","humanize","dom-stale"],"backgroundTag":"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"}