{"record":{"id":"cfd52fbeb447d1c1","repo":"jackwener/OpenCLI","slug":"instagram-reel-caption-editor-did-not-appear","errorCode":null,"errorMessage":"Instagram reel caption editor did not appear","messagePattern":"Instagram reel caption editor did not appear","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/reel.js","lineNumber":422,"sourceCode":"          if (currentText === target || pendingText === target) {\n            return { ok: true };\n          }\n        }\n\n        const value = (editor.textContent || '').replace(/\\\\u00a0/g, ' ').replace(/\\\\s+/g, ' ').trim();\n        if (value === target) {\n          return { ok: true };\n        }\n      }\n      return { ok: false };\n    })()\n  `);\n    return !!result?.ok;\n}\nasync function fillCaption(page, content) {\n    const focused = await focusCaptionEditor(page);\n    if (!focused) {\n        throw new CommandExecutionError('Instagram reel caption editor did not appear');\n    }\n    if (page.insertText) {\n        try {\n            await page.insertText(content);\n            await page.wait({ time: 0.3 });\n            await page.evaluate(`\n        (() => {\n          const isVisible = (el) => {\n            if (!(el instanceof HTMLElement)) return false;\n            const style = window.getComputedStyle(el);\n            const rect = el.getBoundingClientRect();\n            return style.display !== 'none'\n              && style.visibility !== 'hidden'\n              && rect.width > 0\n              && rect.height > 0;\n          };\n          const dialogs = Array.from(document.querySelectorAll('[role=\"dialog\"]')).filter((el) => isVisible(el));\n          for (const dialog of dialogs) {","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/reel.js#L404-L440","documentation":"fillCaption runs an in-page probe (focusCaptionEditor) that looks for a visible [role=\"dialog\"] containing a caption textarea or contenteditable Lexical editor ('Write a caption...'). If no such element is found, the library assumes the caption step of the reel-share dialog did not load and throws this CommandExecutionError instead of typing into a non-existent editor.","triggerScenarios":"The in-page probe returns { ok: false }: no visible dialog, or the dialog has no textarea/contenteditable caption editor. Called from run() during the reel upload flow right after the video preview appears.","commonSituations":"Instagram shipped a DOM change (new aria-labels, no longer using [role=dialog] or contenteditable), a slower connection leaves the dialog still loading when the probe runs (no retry inside focusCaptionEditor), a login/2FA or 'Try again later' interstitial replaced the share dialog, or the flow is stuck on a previous dialog step.","solutions":["Re-run the share; transient dialog slowness is the most common cause, and the surrounding run flow may succeed on retry.","Verify you are actually logged in and that no verification/challenge interstitial is being displayed instead of the share dialog.","Slow down or step through the flow manually (headful mode, less aggressive waits) so the caption dialog has time to render before fillCaption runs.","Update the library / check clis/instagram/reel.js selectors against the current Instagram DOM; if Instagram changed the editor markup the probe needs new selectors."],"exampleFix":"// before\nawait uploadVideo(activePage, preparedUpload.uploadPath, selector);\nawait fillCaption(activePage, caption);\n// after\nawait uploadVideo(activePage, preparedUpload.uploadPath, selector);\nawait waitForVideoPreview(activePage, 10);\nawait activePage.wait({ time: 1 }); // let the caption dialog finish rendering\nawait fillCaption(activePage, caption);","handlingStrategy":"retry","validationCode":"// ensure a logged-in, reel-create-capable session before running\nconst sessionOk = await page.evaluate(() => !!document.querySelector('[role=\"dialog\"]') || location.pathname.includes('/reels'));\nif (!sessionOk) throw new Error('Not on reel-create flow; re-authenticate first');","typeGuard":"null","tryCatchPattern":"try {\n  await client.shareReel({ videoPath, caption });\n} catch (err) {\n  if (String(err.message).includes('caption editor did not appear')) {\n    await sleep(2000); // let the dialog finish rendering\n    await client.shareReel({ videoPath, caption }); // retry once\n  } else throw err;\n}","preventionTips":["Run headful or with generous inter-step waits so Instagram dialogs fully render before automation touches them","Confirm login state and absence of challenge interstitials before each share","Keep the library updated against Instagram DOM changes","Avoid retry-storms; back off when Instagram shows rate-limit notices"],"tags":["instagram","dom-selector","automation","browser-automation"],"backgroundTag":"dom-selector-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}