{"record":{"id":"96160b67ff5dd30c","repo":"jackwener/OpenCLI","slug":"could-not-click-preview-next-label-deb","errorCode":null,"errorMessage":"文字配图: could not click \"${PREVIEW_NEXT_LABEL}\". Debug: /tmp/xhs_publish_next_debug.png","messagePattern":"文字配图: could not click \"(.+?)\"\\. Debug: /tmp/xhs_publish_next_debug\\.png","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/publish.js","lineNumber":1083,"sourceCode":"            if (!added) {\n                await page.screenshot({ path: '/tmp/xhs_publish_addcard_debug.png' });\n                throw new CommandExecutionError(`文字配图: new card editor #${i + 1} did not render after \"${ADD_CARD_LABEL}\". ` +\n                    'Debug: /tmp/xhs_publish_addcard_debug.png');\n            }\n        }\n        await fillCard(page, cards[i], i);\n    }\n    const generated = await clickGenerate(page);\n    if (!generated) {\n        await page.screenshot({ path: '/tmp/xhs_publish_generate_debug.png' });\n        throw new CommandExecutionError(`文字配图: \"${GENERATE_LABEL}\" did not advance to the 预览图片 step. ` +\n            'Debug: /tmp/xhs_publish_generate_debug.png');\n    }\n    const appliedStyle = await selectCardStyle(page, cardStyle);\n    const next = await clickByText(page, PREVIEW_NEXT_LABEL);\n    if (!next?.ok) {\n        await page.screenshot({ path: '/tmp/xhs_publish_next_debug.png' });\n        throw new CommandExecutionError(`文字配图: could not click \"${PREVIEW_NEXT_LABEL}\". ` +\n            'Debug: /tmp/xhs_publish_next_debug.png');\n    }\n    await page.wait({ time: 2 }); // editor render\n    return appliedStyle;\n}\nasync function inspectPublishSurfaceState(page) {\n    return page.evaluate(`\n    () => {\n      const text = (document.body?.innerText || '').replace(/\\s+/g, ' ').trim();\n      const hasTitleInput = !!Array.from(document.querySelectorAll('input, textarea')).find((el) => {\n        if (!el || el.offsetParent === null) return false;\n        const placeholder = (el.getAttribute('placeholder') || '').trim();\n        const cls = el.className ? String(el.className) : '';\n        const maxLength = Number(el.getAttribute('maxlength') || 0);\n        return (\n          placeholder.includes('标题') ||\n          /title/i.test(placeholder) ||\n          /title/i.test(cls) ||","sourceCodeStart":1065,"sourceCodeEnd":1101,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/publish.js#L1065-L1101","documentation":"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.","triggerScenarios":"Text-image publish flow reached the preview step (style selected via selectCardStyle), but clickByText could not find or click the '下一步' button.","commonSituations":"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.","solutions":["Inspect /tmp/xhs_publish_next_debug.png to see the actual preview page state","Add a wait before clicking so preview images finish loading and the button becomes enabled","Check whether '下一步' text changed in the current XHS UI and update PREVIEW_NEXT_LABEL in clis/xiaohongshu/publish.js","Dismiss any modal/dialog visible in the screenshot before proceeding","Retry the publish — transient rendering delays are common"],"exampleFix":"// before\nconst next = await clickByText(page, PREVIEW_NEXT_LABEL);\n// after\nawait page.wait({ time: 3 });\nconst next = await clickByText(page, PREVIEW_NEXT_LABEL);\nif (!next?.ok) {\n  await page.wait({ time: 3 });\n  next = await clickByText(page, PREVIEW_NEXT_LABEL);\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await publish(page, opts);\n} catch (e) {\n  if (String(e.message).includes('could not click')) {\n    // review /tmp/xhs_publish_next_debug.png; wait for preview to finish loading and retry\n  }\n  throw e;\n}","preventionTips":["Allow preview images to fully load before clicking 下一步","Update PREVIEW_NEXT_LABEL whenever XHS changes its UI copy","Handle interstitial dialogs before proceeding","Prefer running publishes during stable network conditions"],"tags":["puppeteer","ui-automation","xiaohongshu","click-failed"],"backgroundTag":"automation-button-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}