xpzouying/xiaohongshu-mcp · error
查找标题输入框失败
Error message
查找标题输入框失败
What it means
submitPublishVideo looks up the title input with the CSS selector div.d-input input; if rod cannot find it within the page timeout, the error is wrapped as "查找标题输入框失败". This indicates the publish page DOM is not in the expected state when the form-fill starts.
Source
Thrown at xiaohongshu/publish_video.go:108
}
fileInput.MustSetFiles(videoPath)
// 对于视频,等待发布按钮变为可点击即表示处理完成
btn, err := waitForPublishButtonClickable(pp, 10*time.Minute)
if err != nil {
return err
}
slog.Info("视频上传/处理完成,发布按钮可点击", "btn", btn)
return nil
}
// submitPublishVideo 填写标题、正文、标签并点击发布(等待按钮可点击后再提交)
func submitPublishVideo(ctx context.Context, page *rod.Page, title, content string, tags []string, scheduleTime *time.Time, visibility string, products []string) error {
// 标题
titleElem, err := page.Element("div.d-input input")
if err != nil {
return errors.Wrap(err, "查找标题输入框失败")
}
if err := humanize.Type(ctx, titleElem, title); err != nil {
return errors.Wrap(err, "输入标题失败")
}
humanize.Delay(ctx, humanize.AfterType)
// 正文 + 标签
contentElem, err := getContentElement(page, contentElemTimeout)
if err != nil {
return err
}
if err := humanize.Type(ctx, contentElem, content); err != nil {
return errors.Wrap(err, "输入正文失败")
}
if err := waitAndClickTitleInput(titleElem); err != nil {
return err
}
if err := inputTags(ctx, contentElem, tags); err != nil {View on GitHub (pinned to 332d196854)
Solutions
- Increase the page timeout (page.Timeout(...)) before element lookup on slow networks
- Verify the session is valid — re-login and refresh cookies if redirected to a login page
- Wait for the editor to be ready (e.g. wait for the video upload to finish / WaitDOMStable) before calling PublishVideo
- Inspect the live page and update the div.d-input input selector to match current markup
Defensive patterns
Strategy: retry
Validate before calling
// pre-check the page is on the publish editor before filling
if err := page.WaitElements("div.d-input input"); err != nil {
return fmt.Errorf("editor not ready: %w", err)
} Try / catch
var titleElem *rod.Element
err := rod.Try(func() { titleElem = page.Timeout(30*time.Second).MustElement("div.d-input input") })
if err != nil {
// retry once after reload, then surface
} Prevention
- Wait for DOM stability / editor readiness before form fill
- Increase element timeouts on slow networks
- Detect login redirects early and re-authenticate
- Pin and periodically re-verify selectors against the live site
When it happens
Trigger: page.Element("div.d-input input") times out because the title field has not rendered yet, the page shows an error/captcha/login dialog instead of the editor, or the site markup changed.
Common situations: Xiaohongshu frontend update renaming the d-input class; network slowness so the editor renders after the default element timeout; session expired and the page redirected to login; video still processing so the form section is hidden.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/1416f4273c7115f3.
Report an issue: GitHub.