{"record":{"id":"19fb265bf17656cc","repo":"jackwener/OpenCLI","slug":"could-not-open-compose-editor","errorCode":null,"errorMessage":"Could not open compose editor.","messagePattern":"Could not open compose editor\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/weibo/publish.js","lineNumber":128,"sourceCode":"            throw new CommandExecutionError('Not logged into Weibo. Please login at weibo.com in your Chrome browser.');\n        }\n\n        // Step 3: Click \"发微博\" button to open inline compose editor\n        const clickResult = await page.evaluate(`\n            () => {\n                const visible = el => !!el && el.offsetParent !== null && !el.disabled;\n                const buttons = document.querySelectorAll('button[title=\"发微博\"], button[title=\"写微博\"]');\n                for (const btn of buttons) {\n                    if (visible(btn)) {\n                        btn.click();\n                        return { ok: true };\n                    }\n                }\n                return { ok: false, message: 'Could not find 发微博 button' };\n            }\n        `);\n        if (!clickResult?.ok) {\n            throw new CommandExecutionError(clickResult?.message ?? 'Could not open compose editor.');\n        }\n\n        // Step 4: Wait for the textarea editor to appear (visible, not just in DOM)\n        let editorFound = false;\n        for (let i = 0; i < Math.ceil(COMPOSE_TIMEOUT_MS / COMPOSE_POLL_MS); i++) {\n            const result = await page.evaluate(`\n                (selectors => {\n                    // Pick the LAST visible match across all selectors so\n                    // the modal (rendered on top of the home-feed strip)\n                    // wins over earlier matches. See TEXTAREA_SELECTORS.\n                    let last = null;\n                    for (const sel of selectors) {\n                        for (const t of document.querySelectorAll(sel)) {\n                            if (t.offsetParent !== null) last = t;\n                        }\n                    }\n                    if (!last) return { found: false };\n                    return { found: true, visible: true, rectTop: last.getBoundingClientRect().top };","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/publish.js#L110-L146","documentation":"Step 3 clicks the 发微博 button via page.evaluate. If the script reports ok:false, the CLI throws CommandExecutionError with the script's message (e.g. 'Could not find 发微博 button'), defaulting to this message when none is present.","triggerScenarios":"The 发微博 button is absent or not clickable — page rendered differently (logged-out, A/B variant, mobile layout), overlay/popup blocking it, or Weibo's DOM/class names changed.","commonSituations":"Weibo frontend redesigns; slow loads where the button has not hydrated yet; regional variants of weibo.com with different chrome; promotions/interstitial dialogs covering the button.","solutions":["Retry after a full page load; add settle time if the button hydrates late","Log in and dismiss any popups/dialogs, then re-run","Update the library in case selectors were fixed for a Weibo DOM change","Use the fallback message in the error to identify which selector failed and patch locally"],"exampleFix":"// before\nweibo publish --text \"hi\"   # button never found\n// after\nawait page.goto('https://weibo.com', { waitUntil: 'load', settleMs: 5000 });\nweibo publish --text \"hi\"","handlingStrategy":"retry","validationCode":"// ensure the feed is fully loaded before publishing\nawait page.goto('https://weibo.com', { waitUntil: 'load', settleMs: 3000 });","typeGuard":null,"tryCatchPattern":"try {\n  await cli.run(['weibo', 'publish', '--text', text]);\n} catch (err) {\n  if (/Could not open compose editor|Could not find/.test(err.message)) {\n    await new Promise(r => setTimeout(r, 3000));\n    await cli.run(['weibo', 'publish', '--text', text]); // one retry\n  } else throw err;\n}","preventionTips":["Allow full page settle before publishing","Dismiss popups/interstitials in the session","Update the library when Weibo ships UI redesigns"],"tags":["browser-automation","weibo","dom-selector"],"backgroundTag":"element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}