{"record":{"id":"0b236d998ca64bc7","repo":"xpzouying/xiaohongshu-mcp","slug":"error","errorCode":null,"errorMessage":"元素当前不可命中","messagePattern":"元素当前不可命中","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"humanize/input.go","lineNumber":74,"sourceCode":"\n\tif pt.X < 0 || pt.Y < 0 || pt.X > size[0] || pt.Y > size[1] {\n\t\treturn fmt.Errorf(\"落点 (%.0f,%.0f) 在视口 %.0fx%.0f 之外\", pt.X, pt.Y, size[0], size[1])\n\t}\n\treturn nil\n}\n\n// 不用 document.elementFromPoint：结果不稳定\nfunc ensureClickable(elem *rod.Element, pt proto.Point) error {\n\tif err := ensurePointInViewport(elem.Page(), pt); err != nil {\n\t\treturn err\n\t}\n\n\tres, err := elem.Eval(`() => getComputedStyle(this).visibility`)\n\tif err != nil {\n\t\treturn nil\n\t}\n\tif res.Value.Str() == \"hidden\" {\n\t\treturn errors.New(\"元素当前不可命中\")\n\t}\n\treturn nil\n}\n\nfunc Click(elem *rod.Element) error {\n\tpt, err := elem.WaitInteractable()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttarget := jitterOn(elem, *pt)\n\tif err := ensureClickable(elem, target); err != nil {\n\t\treturn err\n\t}\n\n\tmouse := elem.Page().Mouse\n\tif err := moveMouseCurved(mouse, target); err != nil {\n\t\treturn err","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/humanize/input.go#L56-L92","documentation":"This error is raised by ensureClickable in humanize/input.go:74. It evaluates getComputedStyle(element).visibility in the browser and fails when the element's computed visibility is 'hidden', i.e. the element exists but is not currently visible/hittable, so a humanized click or hover on it would be pointless or suspicious.","triggerScenarios":"Calling humanize.Click, ClickNoWait, or Hover on an element whose CSS computed visibility is hidden — e.g. a menu item inside a not-yet-opened dropdown, an element behind a collapsed panel, or one animated with visibility:hidden transitions.","commonSituations":"Clicking a 'publish' button that is inside a modal not yet displayed; hovering nav elements in a collapsed menu; animations/transitions still running so visibility is temporarily hidden; page not fully hydrated when the call is made.","solutions":["Ensure the element is visible first: open the parent menu/modal or wait for it via rod's WaitVisible/WaitInteractable before the humanize call","Add a short wait/sleep or rod.WaitStable so CSS transitions finish and visibility becomes 'visible'","Re-query the element — stale node references from a re-rendered DOM often report hidden","If the element is genuinely display:none and will never show, fix the flow logic instead of forcing the click"],"exampleFix":"// before\nbtn, _ := page.Element(\".submit\")\nhumanize.Click(btn)\n// after\nbtn, _ := page.WaitVisible(\".submit\")\npage.WaitStable()\nhumanize.Click(btn)","handlingStrategy":"validation","validationCode":"v, err := elem.Eval(`() => getComputedStyle(this).visibility !== 'hidden'`)\nif err == nil && v.Value.Bool() { /* safe to click */ }","typeGuard":"func isVisible(elem *rod.Element) bool {\n    res, err := elem.Eval(`() => getComputedStyle(this).visibility`)\n    return err == nil && res.Value.Str() == \"visible\"\n}","tryCatchPattern":"if err := humanize.Click(btn); err != nil {\n    if strings.Contains(err.Error(), \"不可命中\") {\n        // wait and retry once after making element visible\n    }\n    return err\n}","preventionTips":["Call WaitVisible/WaitInteractable before humanize actions","Wait for page stability so CSS transitions finish","Re-query elements after SPA re-renders"],"tags":["dom","visibility","go-rod","humanize"],"backgroundTag":"element-not-clickable","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"}