{"record":{"id":"b2eb14bbe4297ab3","repo":"jackwener/OpenCLI","slug":"could-not-find-fieldname-input-debug-screensho","errorCode":null,"errorMessage":"Could not find ${fieldName} input. Debug screenshot: /tmp/xhs_publish_${fieldName}_debug.png","messagePattern":"Could not find (.+?) input\\. Debug screenshot: /tmp/xhs_publish_(.+?)_debug\\.png","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/publish.js","lineNumber":275,"sourceCode":"    const located = await page.evaluate(`\n    (function(selectors) {\n      const __opencli_xhs_fill_phase = \"locate\";\n      for (const sel of selectors) {\n        const candidates = document.querySelectorAll(sel);\n        for (const el of candidates) {\n          if (!el || el.offsetParent === null) continue;\n          const kind = el.isContentEditable\n            ? 'contenteditable'\n            : (el.tagName === 'TEXTAREA' ? 'textarea' : 'input');\n          return { ok: true, sel, kind };\n        }\n      }\n      return { ok: false };\n    })(${JSON.stringify(selectors)})\n  `);\n    if (!located.ok) {\n        await page.screenshot({ path: `/tmp/xhs_publish_${fieldName}_debug.png` });\n        throw new Error(`Could not find ${fieldName} input. Debug screenshot: /tmp/xhs_publish_${fieldName}_debug.png`);\n    }\n    const applyInPage = () => page.evaluate(`\n      ((selector, expectedText) => {\n        const __opencli_xhs_fill_phase = \"apply\";\n        const normalize = (value) => (value || '').replace(/\\\\s+/g, ' ').trim();\n        const fireBeforeInput = (el, value) => {\n          try {\n            el.dispatchEvent(new InputEvent('beforeinput', {\n              bubbles: true,\n              data: value,\n              inputType: 'insertText',\n            }));\n          } catch {\n            el.dispatchEvent(new Event('beforeinput', { bubbles: true }));\n          }\n        };\n        const fireInput = (el, value) => {\n          try {","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/publish.js#L257-L293","documentation":"Thrown by fillField after the in-page locator script reports that none of the candidate CSS selectors for the given field (title/description) matched a visible, editable element. A debug screenshot is saved to /tmp before throwing so you can inspect what the page actually showed.","triggerScenarios":"XHS creator center DOM changed so selectors no longer match; the publish page did not finish rendering before fillField ran; a login wall or verification page replaced the editor; wrong page opened (not the publisher).","commonSituations":"XHS frontend redesign breaking selectors; slow network leaving the editor unrendered; session expired so the tool landed on a login page; running headless where some editor only initializes after interaction.","solutions":["Open /tmp/xhs_publish_<field>_debug.png to see what the page actually rendered.","Add an explicit wait/delay for the editor before publishing, or ensure login cookies are valid.","Check for library updates — XHS DOM changes often break selectors; update the CLI.","Manually confirm the creator publish page loads in your browser session."],"exampleFix":"// before\nawait xhs.publish({ title: 'hi', images: [...], wait: 0 });\n// after\nawait xhs.publish({ title: 'hi', images: [...], wait: 5 }); // let editor render\n// or catch:\ntry { await publish(); } catch (e) {\n  if (e.message.includes('Could not find')) inspect('/tmp/xhs_publish_title_debug.png');\n}","handlingStrategy":"retry","validationCode":"// confirm session can reach the publisher page before publishing\nawait page.goto(PUBLISH_URL);\nif (page.url().includes('login')) throw new Error('not logged in');","typeGuard":null,"tryCatchPattern":"try {\n  await xhs.publish(opts);\n} catch (err) {\n  if (err.message.includes('Could not find') && err.message.includes('input')) {\n    inspectScreenshot('/tmp/xhs_publish_' + field + '_debug.png');\n    await sleep(5000);\n    return retryPublish(opts); // one retry after page settles\n  }\n  throw err;\n}","preventionTips":["Keep login cookies valid so no login wall replaces the editor","Allow generous wait time for the editor to render","Keep the CLI updated — XHS DOM changes break selectors","Check the debug screenshot whenever this fires"],"tags":["puppeteer","dom-selector","automation","xiaohongshu"],"backgroundTag":"selector-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}