{"record":{"id":"76444fce517cc71a","repo":"xpzouying/xiaohongshu-mcp","slug":"error-76444f","errorCode":null,"errorMessage":"查找日期时间输入框失败","messagePattern":"查找日期时间输入框失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":956,"sourceCode":"\tswitchElem, err := page.Element(\".post-time-wrapper .d-switch\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"查找定时发布开关失败\")\n\t}\n\n\tif err := humanize.Click(switchElem); err != nil {\n\t\treturn errors.Wrap(err, \"点击定时发布开关失败\")\n\t}\n\tslog.Info(\"已点击定时发布开关\")\n\treturn nil\n}\n\n// setDateTime 设置日期时间\nfunc setDateTime(ctx context.Context, page *rod.Page, t time.Time) error {\n\tdateTimeStr := t.Format(\"2006-01-02 15:04\")\n\n\telem, err := page.Element(\".date-picker-container input\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"查找日期时间输入框失败\")\n\t}\n\n\t// SelectAllText 走 Eval(this.select())，只改选区、不额外派发事件，暂时保留。\n\t// 换成键盘全选要区分 Ctrl/Cmd，换成三击又可能触发日期控件的其他行为。\n\tif err := elem.SelectAllText(); err != nil {\n\t\treturn errors.Wrap(err, \"选择日期时间文本失败\")\n\t}\n\tif err := humanize.Type(ctx, elem, dateTimeStr); err != nil {\n\t\treturn errors.Wrap(err, \"输入日期时间失败\")\n\t}\n\tslog.Info(\"已设置日期时间\", \"datetime\", dateTimeStr)\n\n\treturn nil\n}\n\n// setOriginal 设置原创声明\nfunc setOriginal(page *rod.Page) error {\n\t// 根据小红书创作者页面的实际结构：","sourceCodeStart":938,"sourceCodeEnd":974,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L938-L974","documentation":"Thrown by setDateTime when page.Element(\".date-picker-container input\") fails to find the date/time input. This input only exists after the schedule toggle was enabled and the date picker panel rendered, so the error means the picker input did not appear within rod's timeout.","triggerScenarios":"The toggle click did not actually enable schedule mode so the picker never renders; the picker renders with different markup after an XHS update; the fixed 800ms sleep in setSchedulePublish is too short and rod's Element timeout also expires.","commonSituations":"XHS redesigns the date-picker container class names; the switch was clicked but the front-end rejected it (schedule time constraints); slow rendering on weak networks.","solutions":["Verify schedule mode actually activated (switch checked) before setDateTime; retry the toggle click if not.","Wait for the picker explicitly instead of a fixed sleep: page.Wait(\"() => !!document.querySelector('.date-picker-container input')\").","Dump page.HTML() on failure and update the selector if XHS changed the markup.","Increase the Element timeout for slow-rendering environments."],"exampleFix":"// before\ntime.Sleep(800 * time.Millisecond)\nelem, err := page.Element(\".date-picker-container input\")\n// after\ntime.Sleep(800 * time.Millisecond)\nif err := page.Wait(\"() => !!document.querySelector('.date-picker-container input')\"); err != nil {\n\treturn errors.Wrap(err, \"日期时间面板未渲染\")\n}\nelem, err := page.Element(\".date-picker-container input\")","handlingStrategy":"validation","validationCode":"if err := page.Wait(\"() => !!document.querySelector('.date-picker-container input')\"); err != nil {\n\treturn fmt.Errorf(\"日期时间输入框未渲染: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := setSchedulePublish(ctx, page, t); err != nil {\n\tif strings.Contains(err.Error(), \"查找日期时间输入框失败\") {\n\t\t// 开关可能未生效：重开定时模式后重试一次\n\t\t_ = clickScheduleSwitch(page)\n\t\ttime.Sleep(1 * time.Second)\n\t\treturn setSchedulePublish(ctx, page, t)\n\t}\n\treturn err\n}","preventionTips":["After clicking the schedule toggle, verify the switch is checked before proceeding.","Replace fixed sleeps with explicit Wait conditions on the picker input.","Dump page HTML on selector failures to detect XHS redesigns early.","Keep generous timeouts for slow-network environments."],"tags":["selector-not-found","go-rod","automation","ui-timeout"],"backgroundTag":"element-selector-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"}