{"record":{"id":"af53a4574356f6db","repo":"jackwener/OpenCLI","slug":"instagram-action-button-not-found-labels-join","errorCode":null,"errorMessage":"Instagram action button not found: ${labels.join(' / ')}","messagePattern":"Instagram action button not found: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/post.js","lineNumber":856,"sourceCode":"        for (const node of nodes) {\n          const text = (node.textContent || '').replace(/\\\\s+/g, ' ').trim();\n          const aria = (node.getAttribute?.('aria-label') || '').replace(/\\\\s+/g, ' ').trim();\n          if (!text && !aria) continue;\n          if (!labels.includes(text) && !labels.includes(aria)) continue;\n          if (node instanceof HTMLElement && isVisible(node) && node.getAttribute('aria-disabled') !== 'true') {\n            node.click();\n            return { ok: true, label: text || aria };\n          }\n        }\n      }\n      return { ok: false };\n    })(${JSON.stringify(labels)}, ${JSON.stringify(scope)})\n  `;\n}\nasync function clickAction(page, labels, scope = 'any') {\n    const result = await page.evaluate(buildClickActionJs(labels, scope));\n    if (!result?.ok) {\n        throw new CommandExecutionError(`Instagram action button not found: ${labels.join(' / ')}`);\n    }\n    return result.label || labels[0];\n}\nasync function clickVisibleShareRetry(page) {\n    const result = 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\n      const dialogs = Array.from(document.querySelectorAll('[role=\"dialog\"]')).filter((el) => isVisible(el));\n      for (const dialog of dialogs) {","sourceCodeStart":838,"sourceCodeEnd":874,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/post.js#L838-L874","documentation":"clickAction evaluates generated JS that locates and clicks one of the labeled action buttons (e.g. Next/Share) within the composer. If the script reports not-ok, meaning no matching button was found in the given scope, the library throws with the joined label list. It marks a step of the publish wizard that could not be advanced.","triggerScenarios":"Called from executeUiInstagramPost or advanceToCaptionEditor; the page.evaluate of buildClickActionJs returns { ok:false } because no button matching any of the labels exists in the searched scope.","commonSituations":"Instagram redesign renaming/moving buttons, wrong scope ('editor' vs 'any') excluding the button, composer still on a prior step, or a modal/overlay intercepting clicks so the button search misses.","solutions":["Retry with scope 'any' so all composer regions are searched for the button","Screenshot the page to see which step of the composer is actually displayed","Update the CLI in case Instagram changed button labels or markup","Wait briefly before the action so the current step finishes rendering","Dismiss any overlays/dialogs (e.g. 'Save login info' prompts) blocking the wizard"],"exampleFix":"// before\nawait clickAction(page, ['Next'], 'editor');\n// after\nawait page.wait({ time: 1 });\nawait clickAction(page, ['Next', 'Next'], 'any'); // broaden labels + scope","handlingStrategy":"retry","validationCode":"const btn = await page.evaluate(() =>\n  ['Next', 'Share'].some(l => [...document.querySelectorAll('button, [role=button]')].some(b => b.textContent.trim().includes(l)))\n);\nif (!btn) await page.wait({ time: 1 });","typeGuard":null,"tryCatchPattern":"try {\n  await clickAction(page, ['Next'], 'editor');\n} catch (e) {\n  if (String(e.message).startsWith('Instagram action button not found')) {\n    await page.wait({ time: 1 });\n    await clickAction(page, ['Next'], 'any'); // broaden scope and retry\n  } else throw e;\n}","preventionTips":["Use scope 'any' unless you specifically need to constrain the search area","Pass multiple label variants to tolerate UI wording differences","Dismiss popups/overlays before wizard clicks"],"tags":["instagram","dom-selector","ui-automation"],"backgroundTag":"selector-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}