jackwener/OpenCLI · error · CommandExecutionError
Could not click publish.
Error message
Could not click publish.
What it means
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.
Source
Thrown at clis/weibo/publish.js:251
const publishResult = await page.evaluate(`
() => {
const visible = el => !!el && el.offsetParent !== null && !el.disabled;
const labels = ['发送', '发布'];
for (const label of labels) {
const allBtns = document.querySelectorAll('button, [role="button"]');
for (const btn of allBtns) {
const t = (btn.innerText || btn.textContent || '').trim();
if (t === label && visible(btn)) {
btn.click();
return { ok: true, label };
}
}
}
return { ok: false, message: 'Could not find send button' };
}
`);
if (!publishResult?.ok) {
throw new CommandExecutionError(publishResult?.message ?? 'Could not click publish.');
}
// Step 8: Wait for success/failure result
// Use page.evaluate (not evaluateWithArgs): the IIFE doesn't reference
// any outer args, and evaluateWithArgs would re-declare its const
// bindings each loop iteration in the same page context, throwing
// "Identifier already declared" after the first iteration.
let finalResult = null;
for (let i = 0; i < Math.ceil(SUBMIT_TIMEOUT_MS / SUBMIT_POLL_MS); i++) {
await page.wait({ time: SUBMIT_POLL_MS / 1000 });
finalResult = await page.evaluate(`
(() => {
const successMarkers = ['发布成功', '已发布', '发送成功'];
const errorMarkers = ['发布失败', '发送失败', '内容违规', '请稍后再试', '频繁'];
for (const el of document.querySelectorAll('*')) {
if (el.children.length > 3) continue;
const txt = (el.innerText || '').trim();
if (!txt || txt.length > 100) continue;View on GitHub (pinned to 49907e53dc)
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)
Defensive patterns
Strategy: retry
Try / catch
try {
await publishToWeibo(text, images);
} catch (err) {
if (String(err.message).includes('Could not click publish')) {
await new Promise(r => setTimeout(r, 2000));
await publishToWeibo(text, images);
} else throw err;
} Prevention
- 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
When it happens
Trigger: page.evaluate publish script returns publishResult with ok:false (button not found, not visible, or click handler failed).
Common situations: 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.
Related errors
- Could not find image file input on Weibo compose page. UI ma
- Could not insert text.
- Could not open compose editor.
- Waiting for 12306 tk auth cookie
- 找不到消息输入框
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/af46a6b63b2293c0.
Report an issue: GitHub.