{"record":{"id":"e4443976e7c9d45b","repo":"jackwener/OpenCLI","slug":"could-not-trigger-actionlabels-0-action-via","errorCode":null,"errorMessage":"Could not trigger \"${actionLabels[0]}\" action${viaClause}${errorClause}${lastMethodClause}. Debug screenshot: /tmp/xhs_publish_submit_debug.png","messagePattern":"Could not trigger \"(.+?)\" action(.+?)(.+?)(.+?)\\. Debug screenshot: /tmp/xhs_publish_submit_debug\\.png","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/publish.js","lineNumber":1406,"sourceCode":"                    const text = (el.innerText || el.textContent || '').trim();\n                    if (text && markers.some(marker => text.includes(marker))) return true;\n                  }\n                  return false;\n                }\n              `);\n                    if (autoSaved) {\n                        invokeResult.ok = true;\n                        invokeResult.via = 'auto-save';\n                    }\n                }\n            }\n        }\n        if (!invokeResult?.ok) {\n            await page.screenshot({ path: '/tmp/xhs_publish_submit_debug.png' });\n            const viaClause = invokeResult?.via ? ` (via=${invokeResult.via})` : '';\n            const errorClause = invokeResult?.error ? `, error=${invokeResult.error}` : '';\n            const lastMethodClause = invokeResult?.lastMethodError ? `, lastMethodError=${invokeResult.lastMethodError}` : '';\n            throw new Error(`Could not trigger \"${actionLabels[0]}\" action${viaClause}${errorClause}${lastMethodClause}. ` +\n                'Debug screenshot: /tmp/xhs_publish_submit_debug.png');\n        }\n        // ── Step 8: Verify success ─────────────────────────────────────────────────\n        await page.wait({ time: 4 });\n        const finalUrl = await page.evaluate('() => location.href');\n        const successMarkers = isDraft\n            ? ['草稿已保存', '暂存成功', '保存成功', '保存于', '图文笔记(']\n            : ['发布成功', '上传成功'];\n        const successMsg = await page.evaluate(`\n      (markers => {\n        for (const el of document.querySelectorAll('*')) {\n          if (el.tagName === 'STYLE' || el.tagName === 'SCRIPT') continue;\n          const text = (el.innerText || '').trim();\n          if (text.length > 200) continue;\n          if (el.children.length === 0 && markers.some(marker => text.includes(marker))) return text;\n        }\n        return '';\n      })(${JSON.stringify(successMarkers)})","sourceCodeStart":1388,"sourceCodeEnd":1424,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/publish.js#L1388-L1424","documentation":"Step 7 of the publish flow tries multiple methods to click the submit/发布 (or 暂存) button. If every invocation method fails, invokeResult.ok is false and the CLI throws with diagnostics: which label it looked for, the via strategy, the per-method error, and the last method's error, plus a debug screenshot.","triggerScenarios":"The submit button could not be found or clicked by any strategy — button text differs from actionLabels[0], the button is disabled, covered by a dialog, or the click dispatch was rejected by the page.","commonSituations":"Required fields missing/invalid so the button stays disabled, an overlay (emoji panel, dialog, captcha) intercepts clicks, xiaohongshu renamed the button (e.g. different 发布 wording), or page hadn't finished rendering.","solutions":["Read viaClause/errorClause/lastMethodClause in the message and inspect /tmp/xhs_publish_submit_debug.png.","Fix any form validation problems (empty description, no cover) that keep the button disabled.","Retry — late rendering or transient overlays often resolve on a second attempt.","Re-capture login if the screenshot shows a captcha/verification dialog; otherwise update the CLI for button-text/DOM changes."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// validate inputs the submit button depends on\nif (!title || !title.trim()) throw new Error('title required before publish');\nif (!description || !description.trim()) throw new Error('description required before publish');","typeGuard":null,"tryCatchPattern":"try {\n  await publish(opts);\n} catch (e) {\n  if (String(e.message).startsWith('Could not trigger')) {\n    console.error('Inspect /tmp/xhs_publish_submit_debug.png:', e.message);\n    await sleep(3000);\n    return publish(opts); // retry once\n  }\n  throw e;\n}","preventionTips":["Ensure all required composer fields (title, description, cover) are provided so the submit button is enabled.","Read via/error/lastMethodError clauses in the message to identify which click strategy failed.","Inspect /tmp/xhs_publish_submit_debug.png for overlays or captchas.","Keep the CLI updated when xiaohongshu renames the 发布/暂存 button."],"tags":["dom-structure","click-failure","browser-automation","xiaohongshu"],"backgroundTag":"click-action-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}