{"record":{"id":"af46a6b63b2293c0","repo":"jackwener/OpenCLI","slug":"could-not-click-publish","errorCode":null,"errorMessage":"Could not click publish.","messagePattern":"Could not click publish\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/weibo/publish.js","lineNumber":251,"sourceCode":"        const publishResult = await page.evaluate(`\n            () => {\n                const visible = el => !!el && el.offsetParent !== null && !el.disabled;\n                const labels = ['发送', '发布'];\n                for (const label of labels) {\n                    const allBtns = document.querySelectorAll('button, [role=\"button\"]');\n                    for (const btn of allBtns) {\n                        const t = (btn.innerText || btn.textContent || '').trim();\n                        if (t === label && visible(btn)) {\n                            btn.click();\n                            return { ok: true, label };\n                        }\n                    }\n                }\n                return { ok: false, message: 'Could not find send button' };\n            }\n        `);\n        if (!publishResult?.ok) {\n            throw new CommandExecutionError(publishResult?.message ?? 'Could not click publish.');\n        }\n\n        // Step 8: Wait for success/failure result\n        // Use page.evaluate (not evaluateWithArgs): the IIFE doesn't reference\n        // any outer args, and evaluateWithArgs would re-declare its const\n        // bindings each loop iteration in the same page context, throwing\n        // \"Identifier already declared\" after the first iteration.\n        let finalResult = null;\n        for (let i = 0; i < Math.ceil(SUBMIT_TIMEOUT_MS / SUBMIT_POLL_MS); i++) {\n            await page.wait({ time: SUBMIT_POLL_MS / 1000 });\n            finalResult = await page.evaluate(`\n                (() => {\n                    const successMarkers = ['发布成功', '已发布', '发送成功'];\n                    const errorMarkers = ['发布失败', '发送失败', '内容违规', '请稍后再试', '频繁'];\n                    for (const el of document.querySelectorAll('*')) {\n                        if (el.children.length > 3) continue;\n                        const txt = (el.innerText || '').trim();\n                        if (!txt || txt.length > 100) continue;","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/publish.js#L233-L269","documentation":"Thrown when the send button could not be clicked: the in-page script failed to find or click 发送 (or fallback 发布) inside the compose editor and returned {ok:false, message:'Could not find send button'} or similar. Without a successful click the post is never submitted, so the command fails immediately rather than waiting for a result.","triggerScenarios":"page.evaluate publish script returns publishResult with ok:false (button not found, not visible, or click handler failed).","commonSituations":"Weibo renamed/relocated the send button in a frontend update; the compose editor lost focus or was re-rendered after text insertion; the post text/images violate some client-side validation that disables the send button; account is restricted (limited posting) so the button is disabled.","solutions":["Retry — a re-render race between text insertion and the button search is common","Check weibo.com manually: is the compose dialog open and the send button enabled?","Update the CLI for refreshed send-button selectors if Weibo shipped a UI change","Verify the account can post manually (restrictions, frequency limits)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    await publishToWeibo(text, images);\n} catch (err) {\n    if (String(err.message).includes('Could not click publish')) {\n        await new Promise(r => setTimeout(r, 2000));\n        await publishToWeibo(text, images);\n    } else throw err;\n}","preventionTips":["Verify the account can post manually (no restrictions/frequency limits)","Keep the CLI updated for Weibo send-button selector changes","Retry once with backoff before giving up","Avoid content that triggers client-side validation disabling the send button"],"tags":["dom-selector","ui-drift","weibo"],"backgroundTag":"selector-stale-dom","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}