{"record":{"id":"90176ae1627aaa89","repo":"xpzouying/xiaohongshu-mcp","slug":"no-p-elements-found","errorCode":null,"errorMessage":"no p elements found","messagePattern":"no p elements found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":764,"sourceCode":"\t\tslog.Warn(\"未找到标签联想选项，直接输入空格\", \"tag\", tag)\n\t\treturn humanize.Type(ctx, contentElem, \" \")\n\t}\n\n\tif err := humanize.Click(firstItem); err != nil {\n\t\treturn errors.Wrap(err, \"点击标签联想选项失败\")\n\t}\n\tslog.Info(\"成功点击标签联想选项\", \"tag\", tag)\n\ttime.Sleep(500 * time.Millisecond) // 技术等待：等标签处理完成\n\treturn nil\n}\n\nfunc findTextboxByPlaceholder(page *rod.Page) (*rod.Element, error) {\n\telements, err := page.Elements(\"p\")\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"查找正文候选元素失败\")\n\t}\n\tif len(elements) == 0 {\n\t\treturn nil, errors.New(\"no p elements found\")\n\t}\n\n\tplaceholderElem := findPlaceholderElement(elements, \"输入正文描述\")\n\tif placeholderElem == nil {\n\t\treturn nil, errors.New(\"no placeholder element found\")\n\t}\n\n\ttextboxElem := findTextboxParent(placeholderElem)\n\tif textboxElem == nil {\n\t\treturn nil, errors.New(\"no textbox parent found\")\n\t}\n\n\treturn textboxElem, nil\n}\n\nfunc findPlaceholderElement(elements []*rod.Element, searchText string) *rod.Element {\n\tfor _, elem := range elements {\n\t\tplaceholder, err := elem.Attribute(\"data-placeholder\")","sourceCodeStart":746,"sourceCodeEnd":782,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L746-L782","documentation":"findTextboxByPlaceholder enumerates all `<p>` elements looking for the description placeholder ('输入正文描述'). If the page has zero `p` elements at query time, it throws 'no p elements found'. This means the content editor area has not rendered at all, or XHS changed its editor markup away from `<p>`-based (ProseMirror/Quill) placeholders.","triggerScenarios":"findContentElement → findTextboxByPlaceholder runs page.Elements(\"p\") on a page where the editor hasn't mounted yet (blank/half-loaded publish page) or where the description box is an iframe/textarea rather than p elements.","commonSituations":"Calling the content-fill step before the publish page finished loading; XHS redesign replacing the p-based rich editor; mobile vs desktop page variants with different editors; navigation happened before this step so the queried page is wrong.","solutions":["Wait for the editor container to appear before calling findContentElement (e.g. page.Element on the editor wrapper with a timeout)","Retry after a short sleep — editor may be mid-render","If XHS changed the editor, update the selector (check for [contenteditable], textarea, or new placeholder text)","Confirm the browser is actually on the publish page before filling content"],"exampleFix":"// before\nelements, err := page.Elements(\"p\")\nif len(elements) == 0 {\n\treturn nil, errors.New(\"no p elements found\")\n}\n// after\nelements, err := page.Elements(\"p\")\nif len(elements) == 0 {\n\t_ = page.WaitElementsMoreThan(\"p\", 0, 5*time.Second) // 等编辑器渲染\n\telements, _ = page.Elements(\"p\")\n\tif len(elements) == 0 {\n\t\treturn nil, errors.New(\"no p elements found\")\n\t}\n}","handlingStrategy":"validation","validationCode":"// 填正文前确认编辑器已渲染\nif _, err := page.Element(\".editor-container, [contenteditable='true']\"); err != nil {\n\treturn errors.New(\"发布页编辑器尚未渲染，请稍候再填正文\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wait for the editor container to mount before filling the description","Confirm the page is on /publish/publish before content steps","After XHS frontend updates, re-verify that the description editor still uses <p> placeholder elements"],"tags":["dom","selector","editor","xiaohongshu"],"backgroundTag":"editor-element-not-found","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"}