{"record":{"id":"68ca97f3953714b7","repo":"jackwener/OpenCLI","slug":"could-not-find-doubao-input-element","errorCode":null,"errorMessage":"Could not find Doubao input element","messagePattern":"Could not find Doubao input element","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clis/doubao/utils.js","lineNumber":392,"sourceCode":"      if (composer instanceof HTMLElement) {\n        const text = (composer.innerText || '').trim() || (composer.textContent || '').trim();\n        composer.dispatchEvent(new InputEvent('beforeinput', { bubbles: true, data: text, inputType: 'insertText' }));\n        composer.dispatchEvent(new InputEvent('input', { bubbles: true, data: text, inputType: 'insertText' }));\n        composer.dispatchEvent(new Event('change', { bubbles: true }));\n        return { hasText: !!text, text };\n      }\n\n      return { hasText: false, text: '' };\n    })()\n  `;\n}\nfunction fillComposerScript(text) {\n    return `\n    ((inputText) => {\n      ${buildDoubaoComposerLocatorScript()}\n      const composer = findComposer();\n\n      if (!composer) throw new Error('Could not find Doubao input element');\n\n      composer.focus();\n\n      if (composer instanceof HTMLTextAreaElement || composer instanceof HTMLInputElement) {\n        const proto = composer instanceof HTMLTextAreaElement\n          ? window.HTMLTextAreaElement.prototype\n          : window.HTMLInputElement.prototype;\n        const setter = Object.getOwnPropertyDescriptor(proto, 'value')?.set;\n        setter?.call(composer, inputText);\n        composer.dispatchEvent(new InputEvent('beforeinput', { bubbles: true, data: inputText, inputType: 'insertText' }));\n        composer.dispatchEvent(new InputEvent('input', { bubbles: true, data: inputText, inputType: 'insertText' }));\n        composer.dispatchEvent(new Event('change', { bubbles: true }));\n        return { hasText: !!composer.value.trim(), mode: 'text-input', text: composer.value };\n      }\n\n      if (composer instanceof HTMLElement) {\n        composer.textContent = '';\n        const selection = window.getSelection();","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/doubao/utils.js#L374-L410","documentation":"fillComposerScript injects a script that locates the Doubao message composer via buildDoubaoComposerLocatorScript(); if findComposer() returns nothing, the in-page script throws 'Could not find Doubao input element'. fillComposerScript is the fallback text-insertion path in sendDoubaoMessage, so this means neither DOM handle nor native typing could find the composer.","triggerScenarios":"Called from sendDoubaoMessage's fallback when the primary prepare/nativeType steps found no composer; findComposer() matches no textarea, input, or contenteditable element on the current Doubao page.","commonSituations":"Doubao changed its composer markup after a site update; page stuck on login/verification interstitial; user navigated away from a chat page; page still hydrating when the script runs.","solutions":["Ensure the browser is on a Doubao chat page (use ensureDoubaoChatPage / navigate to the chat URL first)","Wait for the page to finish loading and retry the send","Complete any login or verification challenge shown in the browser","Update the library if Doubao changed composer markup"],"exampleFix":"// before\nawait page.evaluate(fillComposerScript(text));\n// after\nawait ensureDoubaoChatPage(page);\nawait page.wait(1); // let composer hydrate\nconst st = await page.evaluate(fillComposerScript(text));\nif (!st?.hasText) throw new CommandExecutionError('Composer not found; is the Doubao chat page loaded?');","handlingStrategy":"validation","validationCode":"const found = await page.evaluate(() => !!document.querySelector('textarea, [contenteditable=\"true\"], input'));\nif (!found) throw new Error('Doubao composer not present; navigate to a chat page first');","typeGuard":"function isComposer(el) {\n  return el instanceof HTMLTextAreaElement || el instanceof HTMLInputElement || el?.isContentEditable === true;\n}","tryCatchPattern":"try {\n  await page.evaluate(fillComposerScript(text));\n} catch (e) {\n  if (/Could not find Doubao input element/.test(e.message)) {\n    await ensureDoubaoChatPage(page);\n    await page.wait(1);\n    await page.evaluate(fillComposerScript(text));\n  } else throw e;\n}","preventionTips":["Always call ensureDoubaoChatPage before composer interactions","Wait for hydration before querying the DOM","Detect Doubao UI/version changes and assert composer selectors in smoke tests","Complete login/captcha screens before sending messages"],"tags":["doubao","dom-locator","composer","page-evaluate"],"backgroundTag":"element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}