jackwener/OpenCLI · error · CommandExecutionError

文字配图: could not click "${PREVIEW_NEXT_LABEL}". Debug: /tmp/x

Error message

文字配图: could not click "${PREVIEW_NEXT_LABEL}". Debug: /tmp/xhs_publish_next_debug.png

What it means

Thrown when the '下一步' (next) button on the 预览图片 preview step could not be clicked. `clickByText(page, PREVIEW_NEXT_LABEL)` returned an object without `ok`, meaning no clickable element with that text was found or the click failed. A debug screenshot is saved to /tmp/xhs_publish_next_debug.png before throwing.

Source

Thrown at clis/xiaohongshu/publish.js:1083

            if (!added) {
                await page.screenshot({ path: '/tmp/xhs_publish_addcard_debug.png' });
                throw new CommandExecutionError(`文字配图: new card editor #${i + 1} did not render after "${ADD_CARD_LABEL}". ` +
                    'Debug: /tmp/xhs_publish_addcard_debug.png');
            }
        }
        await fillCard(page, cards[i], i);
    }
    const generated = await clickGenerate(page);
    if (!generated) {
        await page.screenshot({ path: '/tmp/xhs_publish_generate_debug.png' });
        throw new CommandExecutionError(`文字配图: "${GENERATE_LABEL}" did not advance to the 预览图片 step. ` +
            'Debug: /tmp/xhs_publish_generate_debug.png');
    }
    const appliedStyle = await selectCardStyle(page, cardStyle);
    const next = await clickByText(page, PREVIEW_NEXT_LABEL);
    if (!next?.ok) {
        await page.screenshot({ path: '/tmp/xhs_publish_next_debug.png' });
        throw new CommandExecutionError(`文字配图: could not click "${PREVIEW_NEXT_LABEL}". ` +
            'Debug: /tmp/xhs_publish_next_debug.png');
    }
    await page.wait({ time: 2 }); // editor render
    return appliedStyle;
}
async function inspectPublishSurfaceState(page) {
    return page.evaluate(`
    () => {
      const text = (document.body?.innerText || '').replace(/\s+/g, ' ').trim();
      const hasTitleInput = !!Array.from(document.querySelectorAll('input, textarea')).find((el) => {
        if (!el || el.offsetParent === null) return false;
        const placeholder = (el.getAttribute('placeholder') || '').trim();
        const cls = el.className ? String(el.className) : '';
        const maxLength = Number(el.getAttribute('maxlength') || 0);
        return (
          placeholder.includes('标题') ||
          /title/i.test(placeholder) ||
          /title/i.test(cls) ||

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Inspect /tmp/xhs_publish_next_debug.png to see the actual preview page state
  2. Add a wait before clicking so preview images finish loading and the button becomes enabled
  3. Check whether '下一步' text changed in the current XHS UI and update PREVIEW_NEXT_LABEL in clis/xiaohongshu/publish.js
  4. Dismiss any modal/dialog visible in the screenshot before proceeding
  5. Retry the publish — transient rendering delays are common

Example fix

// before
const next = await clickByText(page, PREVIEW_NEXT_LABEL);
// after
await page.wait({ time: 3 });
const next = await clickByText(page, PREVIEW_NEXT_LABEL);
if (!next?.ok) {
  await page.wait({ time: 3 });
  next = await clickByText(page, PREVIEW_NEXT_LABEL);
}
Defensive patterns

Strategy: retry

Try / catch

try {
  await publish(page, opts);
} catch (e) {
  if (String(e.message).includes('could not click')) {
    // review /tmp/xhs_publish_next_debug.png; wait for preview to finish loading and retry
  }
  throw e;
}

Prevention

When it happens

Trigger: Text-image publish flow reached the preview step (style selected via selectCardStyle), but clickByText could not find or click the '下一步' button.

Common situations: The preview page is still loading images and the button is disabled/absent; XHS changed the button label; an interstitial dialog (confirm, upsell) covers the button; card style selection left the page in a state where '下一步' is replaced by another action.

Related errors


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