jackwener/OpenCLI · error

Could not find ${fieldName} input. Debug screenshot: /tmp/xh

Error message

Could not find ${fieldName} input. Debug screenshot: /tmp/xhs_publish_${fieldName}_debug.png

What it means

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.

Source

Thrown at clis/xiaohongshu/publish.js:275

    const located = await page.evaluate(`
    (function(selectors) {
      const __opencli_xhs_fill_phase = "locate";
      for (const sel of selectors) {
        const candidates = document.querySelectorAll(sel);
        for (const el of candidates) {
          if (!el || el.offsetParent === null) continue;
          const kind = el.isContentEditable
            ? 'contenteditable'
            : (el.tagName === 'TEXTAREA' ? 'textarea' : 'input');
          return { ok: true, sel, kind };
        }
      }
      return { ok: false };
    })(${JSON.stringify(selectors)})
  `);
    if (!located.ok) {
        await page.screenshot({ path: `/tmp/xhs_publish_${fieldName}_debug.png` });
        throw new Error(`Could not find ${fieldName} input. Debug screenshot: /tmp/xhs_publish_${fieldName}_debug.png`);
    }
    const applyInPage = () => page.evaluate(`
      ((selector, expectedText) => {
        const __opencli_xhs_fill_phase = "apply";
        const normalize = (value) => (value || '').replace(/\\s+/g, ' ').trim();
        const fireBeforeInput = (el, value) => {
          try {
            el.dispatchEvent(new InputEvent('beforeinput', {
              bubbles: true,
              data: value,
              inputType: 'insertText',
            }));
          } catch {
            el.dispatchEvent(new Event('beforeinput', { bubbles: true }));
          }
        };
        const fireInput = (el, value) => {
          try {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open /tmp/xhs_publish_<field>_debug.png to see what the page actually rendered.
  2. Add an explicit wait/delay for the editor before publishing, or ensure login cookies are valid.
  3. Check for library updates — XHS DOM changes often break selectors; update the CLI.
  4. Manually confirm the creator publish page loads in your browser session.

Example fix

// before
await xhs.publish({ title: 'hi', images: [...], wait: 0 });
// after
await xhs.publish({ title: 'hi', images: [...], wait: 5 }); // let editor render
// or catch:
try { await publish(); } catch (e) {
  if (e.message.includes('Could not find')) inspect('/tmp/xhs_publish_title_debug.png');
}
Defensive patterns

Strategy: retry

Validate before calling

// confirm session can reach the publisher page before publishing
await page.goto(PUBLISH_URL);
if (page.url().includes('login')) throw new Error('not logged in');

Try / catch

try {
  await xhs.publish(opts);
} catch (err) {
  if (err.message.includes('Could not find') && err.message.includes('input')) {
    inspectScreenshot('/tmp/xhs_publish_' + field + '_debug.png');
    await sleep(5000);
    return retryPublish(opts); // one retry after page settles
  }
  throw err;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/b2eb14bbe4297ab3. Report an issue: GitHub.