{"record":{"id":"86694b711e8b2faa","repo":"jackwener/OpenCLI","slug":"visible-midjourney-control-label-was-not-foun","errorCode":null,"errorMessage":"Visible Midjourney control \"${label}\" was not found","messagePattern":"Visible Midjourney control \"(.+?)\" was not found","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":1240,"sourceCode":"  return target;\n}\n\nexport async function clickVisibleControl(page, label) {\n  const target = unwrapEvaluateResult(await page.evaluate((wanted) => {\n    const visible = (element) => {\n      const rect = element.getBoundingClientRect();\n      return rect.width > 0 && rect.height > 0 && getComputedStyle(element).display !== 'none';\n    };\n    const button = [...document.querySelectorAll('button')].find((node) => visible(node) && (\n      node.textContent?.trim().replace(/\\s+/g, ' ') === wanted\n      || node.title === wanted\n      || node.getAttribute('aria-label') === wanted\n    ));\n    if (!button || button.disabled) return null;\n    const rect = button.getBoundingClientRect();\n    return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };\n  }, label));\n  if (!target) throw new CommandExecutionError(`Visible Midjourney control \"${label}\" was not found`);\n  if (typeof page.nativeClick !== 'function') throw new CommandExecutionError('Browser Bridge native click support is required');\n  await page.nativeClick(target.x, target.y);\n}\n\nexport async function clickComposerSubmit(page) {\n  const marked = unwrapEvaluateResult(await page.evaluate(() => {\n    document.querySelectorAll('[data-opencli-composer-submit]').forEach((node) => {\n      node.removeAttribute('data-opencli-composer-submit');\n    });\n    const visible = (element) => {\n      const rect = element.getBoundingClientRect();\n      return rect.width > 0 && rect.height > 0 && getComputedStyle(element).display !== 'none';\n    };\n    const input = document.querySelector('#desktop_input_bar');\n    const row = input?.parentElement;\n    if (!input || !row) return false;\n    const textSubmit = [...row.querySelectorAll('button')]\n      .find((button) => visible(button) && button.textContent?.trim() === 'Submit');","sourceCodeStart":1222,"sourceCodeEnd":1258,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L1222-L1258","documentation":"CommandExecutionError thrown when clickVisibleControl cannot find an enabled visible button matching the given label (matched by text or aria-label). The in-page lookup returns null when no match exists or the match is disabled.","triggerScenarios":"clickVisibleControl(page, label) where no rendered button/element has exactly that text or aria-label, or the matching element is disabled.","commonSituations":"Typo or different casing in the label; control not currently rendered (collapsed menu, wrong tab); element is a div not matching the selector; button disabled because a job is running.","solutions":["Confirm the exact visible label/aria-label in the UI and pass it verbatim.","Open/expand the panel containing the control before clicking.","Wait for the control to become enabled (job completion) and retry.","List visible controls first (clickVisibleControl-style enumeration) to debug matching."],"exampleFix":"// before\nawait clickVisibleControl(page, 'U1');\n// after\nawait page.wait(1); // ensure grid rendered\nawait clickVisibleControl(page, 'U1');","handlingStrategy":"validation","validationCode":"const exists = await page.evaluate((label) =>\n  [...document.querySelectorAll('button,[role=button]')].some(b =>\n    !b.disabled && (b.textContent?.trim() === label || b.getAttribute('aria-label') === label)), label);\nif (!exists) throw new Error(`Control \"${label}\" is not visible/enabled`);","typeGuard":null,"tryCatchPattern":"try {\n  await clickVisibleControl(page, label);\n} catch (err) {\n  if (String(err.message).includes('was not found')) {\n    await page.wait(2);\n    await clickVisibleControl(page, label);\n  } else throw err;\n}","preventionTips":["Pass labels verbatim from the UI","Expand menus/panels so the control is rendered","Wait for async content before clicking","Retry once for late-rendered controls"],"tags":["midjourney","dom","selector","ui-automation"],"backgroundTag":"ui-control-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}