{"record":{"id":"0bb3115312236926","repo":"xpzouying/xiaohongshu-mcp","slug":"error-0bb311","errorCode":null,"errorMessage":"查找标题输入框失败","messagePattern":"查找标题输入框失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":347,"sourceCode":"\t\tif currentCount != lastLogCount {\n\t\t\tslog.Info(\"等待图片上传\", \"current\", currentCount, \"expected\", expectedCount)\n\t\t\tlastLogCount = currentCount\n\t\t}\n\t\tif currentCount >= expectedCount {\n\t\t\tslog.Info(\"图片上传完成\", \"count\", currentCount)\n\t\t\treturn nil\n\t\t}\n\n\t\ttime.Sleep(checkInterval)\n\t}\n\n\treturn errors.Errorf(\"第%d张图片上传超时(60s)，请检查网络连接和图片大小\", expectedCount)\n}\n\nfunc submitPublish(ctx context.Context, page *rod.Page, title, content string, tags []string, scheduleTime *time.Time, isOriginal bool, visibility string, products []string) error {\n\ttitleElem, err := page.Element(\"div.d-input input\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"查找标题输入框失败\")\n\t}\n\tif err := humanize.Type(ctx, titleElem, title); err != nil {\n\t\treturn errors.Wrap(err, \"输入标题失败\")\n\t}\n\n\thumanize.Delay(ctx, humanize.AfterType)\n\tif err := checkTitleMaxLength(page); err != nil {\n\t\treturn err\n\t}\n\tslog.Info(\"检查标题长度：通过\")\n\n\thumanize.Delay(ctx, humanize.AfterType)\n\n\tcontentElem, err := getContentElement(page, contentElemTimeout)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := humanize.Type(ctx, contentElem, content); err != nil {","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L329-L365","documentation":"submitPublish locates the post title field with page.Element(\"div.d-input input\") using rod's default timeout. If the selector matches no element before timing out, the rod error is wrapped as '查找标题输入框失败'. This almost always means the publish page did not render the expected title input, or the site's markup changed.","triggerScenarios":"Publish → submitPublish where page.Element(\"div.d-input input\") times out because no title input exists on the page (xiaohongshu/publish.go:347).","commonSituations":"Not logged in or session expired so the creator page redirected; the publish page failed to load fully; Xiaohongshu changed the title input markup away from div.d-input; navigating to the wrong page type (e.g. video publish tab with a different form).","solutions":["Verify the login session is valid and the creator publish page actually loaded (screenshot the page on failure)","Open the publish page and inspect the title input; if markup changed, update the selector 'div.d-input input'","Ensure the correct publish tab (图文) is active before submitPublish runs","Add a longer/explicit timeout or wait for page stability before querying the element"],"exampleFix":"// before\ntitleElem, err := page.Element(\"div.d-input input\")\n// after\ntitleElem, err := page.Timeout(30 * time.Second).Element(\"div.d-input input\") // 或更新为站点新选择器","handlingStrategy":"try-catch","validationCode":"// 调用前确认登录态与发布页可达\nif !bot.IsLoggedIn(ctx) { return errors.New(\"登录已过期\") }","typeGuard":null,"tryCatchPattern":"err := bot.Publish(ctx, post, images)\nif err != nil && strings.Contains(err.Error(), \"查找标题输入框失败\") {\n    // 截图排查: 登录态/页面跳转/选择器过期\n}","preventionTips":["Verify the login session is fresh before publishing","Confirm the 图文 publish tab is loaded before form interaction","Track Xiaohongshu markup changes and update the div.d-input input selector","Screenshot on failure to diagnose page state"],"tags":["dom-selector","browser-automation","timeout"],"backgroundTag":"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"}