{"record":{"id":"4777cc5699403cf6","repo":"xpzouying/xiaohongshu-mcp","slug":"error-4777cc","errorCode":null,"errorMessage":"获取新版发布按钮位置失败: 无可点击区域","messagePattern":"获取新版发布按钮位置失败: 无可点击区域","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":556,"sourceCode":"\n\t\treturn &publishButton{elem: oldButton}, \"\", nil\n\t}\n\n\treturn nil, \"\", nil\n}\n\nfunc clickPublishWidget(page *rod.Page, widget *rod.Element) error {\n\tif err := widget.ScrollIntoView(); err != nil {\n\t\treturn errors.Wrap(err, \"滚动新版发布按钮到可视区域失败\")\n\t}\n\ttime.Sleep(200 * time.Millisecond)\n\n\tshape, err := widget.Shape()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"获取新版发布按钮位置失败\")\n\t}\n\tif len(shape.Quads) == 0 {\n\t\treturn errors.New(\"获取新版发布按钮位置失败: 无可点击区域\")\n\t}\n\n\tquad := shape.Quads[0]\n\tminX, maxX := quad[0], quad[0]\n\tminY, maxY := quad[1], quad[1]\n\tfor i := 0; i < quad.Len(); i++ {\n\t\tx := quad[i*2]\n\t\ty := quad[i*2+1]\n\t\tif x < minX {\n\t\t\tminX = x\n\t\t}\n\t\tif x > maxX {\n\t\t\tmaxX = x\n\t\t}\n\t\tif y < minY {\n\t\t\tminY = y\n\t\t}\n\t\tif y > maxY {","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L538-L574","documentation":"clickPublishWidget resolves the click coordinates of the new-version publish button (custom element `xhs-publish-btn`) from its rod Shape(). If Shape() succeeds but shape.Quads is empty, there is no clickable geometry to compute a click point, so this error is thrown. This usually means the element exists in the DOM but is not rendered (zero size, display:none, or inside a collapsed container).","triggerScenarios":"clickPublishButton → clickPublishWidget calls widget.Shape(); quads list is empty because the custom element has no layout box — page not fully rendered, element hidden by CSS, or element detached/replaced right before Shape().","commonSituations":"Publish page still animating/rendering when clicked; XHS serving a variant where the button is nested such that the outer custom element has no box; headless viewport too small causing the element to not lay out; race where the page re-renders between finding and shaping the element.","solutions":["Wait for the element to be visible/stable (WaitVisible or WaitStable) before calling clickPublishWidget","Retry the click once after a short sleep — transient layout races often resolve","Fall back to the legacy publish-button selector path if the new-version widget renders empty","Ensure a reasonable viewport size in headless mode (e.g. 1280x800) so all elements lay out"],"exampleFix":"// before\nif len(shape.Quads) == 0 {\n\treturn errors.New(\"获取新版发布按钮位置失败: 无可点击区域\")\n}\n// after\nif len(shape.Quads) == 0 {\n\t_ = widget.WaitStable(300 * time.Millisecond) // then retry Shape() once\n\tshape, err = widget.Shape()\n\tif err != nil || len(shape.Quads) == 0 {\n\t\treturn errors.New(\"获取新版发布按钮位置失败: 无可点击区域\")\n\t}\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := clickPublishButton(page); err != nil {\n\tif strings.Contains(err.Error(), \"无可点击区域\") {\n\t\ttime.Sleep(1 * time.Second)\n\t\treturn clickPublishButton(page) // 布局稳定后重试\n\t}\n\treturn err\n}","preventionTips":["Wait for the button to be visible/stable before resolving its Shape()","Use a normal desktop viewport (e.g. 1280x800) in headless mode","Retry once on geometry errors — they are usually transient render races"],"tags":["dom","geometry","custom-element","xiaohongshu"],"backgroundTag":"element-shape-no-quads","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"}