xpzouying/xiaohongshu-mcp · error
点击声明原创按钮失败
Error message
点击声明原创按钮失败
What it means
confirmOriginalDeclaration wraps a humanize.Click failure on the '声明原创' (declare original) button with this message. The button was found and appeared enabled, but the simulated click itself failed (element detached, intercepted, or CDP action error). It indicates a DOM instability or overlay issue at click time, not a missing button.
Source
Thrown at xiaohongshu/publish.go:1069
btn, err := footer.Element("button.custom-button")
if err != nil {
return errors.Wrap(err, "未找到声明原创按钮")
}
if isButtonDisabled(btn) {
// 兜底:按钮仍禁用,可能须知未勾上,再勾一次
if err := checkFooterCheckbox(footer); err != nil {
slog.Warn("二次勾选须知失败", "error", err)
}
time.Sleep(300 * time.Millisecond)
if isButtonDisabled(btn) {
return errors.New("声明原创按钮仍处于禁用状态")
}
}
if err := humanize.Click(btn); err != nil {
return errors.Wrap(err, "点击声明原创按钮失败")
}
slog.Info("已成功点击声明原创按钮")
time.Sleep(300 * time.Millisecond)
return nil
}
func findFooterByText(page *rod.Page, keyword string) (*rod.Element, error) {
footers, err := page.Elements("div.footer")
if err != nil {
return nil, errors.Wrap(err, "查找弹窗 footer 失败")
}
for _, footer := range footers {
text, err := footer.Text()
if err != nil {
continue
}
if strings.Contains(text, keyword) {
return footer, nilView on GitHub (pinned to 332d196854)
Solutions
- Retry confirmOriginalDeclaration once after a short delay; transient detach often resolves
- Check logs for the preceding '勾选原创声明须知失败' warning — fix checkbox selection so the button stays stable
- Increase waits before clicking (the 300/500ms sleeps) or use rod's WaitStable/WaitVisible on the button
- Verify the page/browser wasn't closed or navigated by another goroutine
Example fix
// before
if err := humanize.Click(btn); err != nil {
return errors.Wrap(err, "点击声明原创按钮失败")
}
// after
if err := btn.WaitVisible(); err != nil { return err }
if err := btn.WaitStable(); err != nil { return err }
if err := humanize.Click(btn); err != nil {
return errors.Wrap(err, "点击声明原创按钮失败")
} Defensive patterns
Strategy: retry
Validate before calling
// before calling the publish flow
if page == nil { return errors.New("page is nil") }
if _, err := page.Info(); err != nil { return fmt.Errorf("page not alive: %w", err) } Try / catch
for attempt := 0; attempt < 3; attempt++ {
err := confirmOriginalDeclaration(page)
if err == nil || !strings.Contains(err.Error(), "点击声明原创按钮失败") { break }
time.Sleep(time.Second)
} Prevention
- Wait for the button to be stable/visible before clicking instead of fixed sleeps
- Fix checkbox selection first so the button state doesn't shift mid-click
- Keep the page open and avoid concurrent navigation during publish
- Log the inner error to distinguish detach vs overlay vs closed page
When it happens
Trigger: The confirm-originality dialog's footer button was located but humanize.Click failed: the dialog re-rendered between isButtonDisabled check and click, an overlay/toast covers the button, or the rod page/browser context was lost mid-click.
Common situations: Slow page rendering on the Xiaohongshu publish flow causing mid-click DOM replacement; the '须知' checkbox click silently failed so UI state shifted; headless environments where animation timing differs.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/edeafb7d6a19f8f7.
Report an issue: GitHub.