{"record":{"id":"c8936b13a209d63c","repo":"jackwener/OpenCLI","slug":"could-not-click-text-image-entry-label","errorCode":null,"errorMessage":"文字配图: could not click \"${TEXT_IMAGE_ENTRY_LABEL}\" entry. Debug: /tmp/xhs_publish_textimage_debug.png","messagePattern":"文字配图: could not click \"(.+?)\" entry\\. Debug: /tmp/xhs_publish_textimage_debug\\.png","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/publish.js","lineNumber":1054,"sourceCode":"    const state = await currentComposerMediaCount(page);\n    if (!state || typeof state.count !== 'number') {\n        throw new CommandExecutionError(`${label}: could not verify current composer media count`);\n    }\n    if (state.count < expectedCount) {\n        await page.screenshot({ path: '/tmp/xhs_publish_media_debug.png' });\n        throw new CommandExecutionError(`${label}: expected at least ${expectedCount} visible media item(s), got ${state.count}. ` +\n            'Debug screenshot: /tmp/xhs_publish_media_debug.png');\n    }\n}\n/**\n * Drive the full 文字配图 sub-flow: entry → type cards → 生成图片 → pick style → 下一步.\n * Leaves the page on the standard editor (caller then runs waitForEditForm).\n */\nasync function runTextImageFlow(page, cards, cardStyle) {\n    const entry = await clickByText(page, TEXT_IMAGE_ENTRY_LABEL);\n    if (!entry?.ok) {\n        await page.screenshot({ path: '/tmp/xhs_publish_textimage_debug.png' });\n        throw new CommandExecutionError(`文字配图: could not click \"${TEXT_IMAGE_ENTRY_LABEL}\" entry. ` +\n            'Debug: /tmp/xhs_publish_textimage_debug.png');\n    }\n    if (!(await waitForFirstCard(page))) {\n        await page.screenshot({ path: '/tmp/xhs_publish_textimage_debug.png' });\n        throw new CommandExecutionError(`文字配图: 写文字 card editor did not appear after clicking \"${TEXT_IMAGE_ENTRY_LABEL}\". ` +\n            'Debug: /tmp/xhs_publish_textimage_debug.png');\n    }\n    for (let i = 0; i < cards.length; i++) {\n        if (i > 0) {\n            const added = await addCard(page, i + 1);\n            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    }","sourceCodeStart":1036,"sourceCodeEnd":1072,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/publish.js#L1036-L1072","documentation":"runTextImageFlow starts the 文字配图 sub-flow by clicking the entry button found via its label (TEXT_IMAGE_ENTRY_LABEL, e.g. the 文字配图 option on the media picker). If clickByText can't click it, a debug screenshot is saved to /tmp/xhs_publish_textimage_debug.png and this error is thrown.","triggerScenarios":"clickByText(page, TEXT_IMAGE_ENTRY_LABEL) returned { ok: false } — entry button not rendered yet, hidden behind an 'add media' popup that hasn't opened, label text changed, or an overlay intercepted the click.","commonSituations":"Media picker step not fully loaded; XHS renamed/relocated the 文字配图 entry; slow network so the entry card lazy-loads after the click attempt; multiple similar entries confusing text matching.","solutions":["Inspect /tmp/xhs_publish_textimage_debug.png to see the actual page state at failure.","Retry with a wait before the flow so the media picker finishes rendering.","Retry outright — click races on the lazy-loaded entry are often transient.","If XHS changed the label, update TEXT_IMAGE_ENTRY_LABEL to match the current on-page text."],"exampleFix":"// before\nawait runTextImageFlow(page, cards, style);\n// after\nawait page.wait({ time: 2.0 }); // ensure media picker rendered\ntry {\n  await runTextImageFlow(page, cards, style);\n} catch (e) {\n  if (/could not click .* entry/.test(e.message)) {\n    await page.wait({ time: 3.0 });\n    await runTextImageFlow(page, cards, style);\n  } else throw e;\n}","handlingStrategy":"retry","validationCode":"await page.wait({ time: 2.0 }); // media picker must be visible first\n// optionally assert the entry label exists:\nconst found = await page.evaluate(`document.body.innerText.includes('${TEXT_IMAGE_ENTRY_LABEL}')`);\nif (!found) console.warn('文字配图 entry not on page yet');","typeGuard":"null","tryCatchPattern":"try { await runTextImageFlow(page, cards, style); }\ncatch (e) {\n  if (/could not click .* entry/.test(e.message)) {\n    await page.wait({ time: 3.0 });\n    await runTextImageFlow(page, cards, style);\n  } else throw e;\n}","preventionTips":["Wait for the media picker to fully render before clicking the entry","Check /tmp/xhs_publish_textimage_debug.png on failure","Update TEXT_IMAGE_ENTRY_LABEL if XHS renames the entry"],"tags":["browser-automation","click-failure","ui-timing"],"backgroundTag":"entry-click-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}