{"record":{"id":"e5b2faa465a5d100","repo":"can1357/oh-my-pi","slug":"no-element-matched-spec-raw","errorCode":null,"errorMessage":"No element matched ${spec.raw}","messagePattern":"No element matched (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/browser/cmux/cmux-tab.ts","lineNumber":910,"sourceCode":"\t\t\t\t\tawait this.#request(\"browser.scroll_into_view\", { selector: nativeSelector });\n\t\t\t\t\treturn undefined as TResult;\n\t\t\t}\n\t\t}\n\t\treturn await this.#evalSelectorAction<TResult>(spec, action, args);\n\t}\n\n\tasync #evalSelectorAction<TResult>(\n\t\tspec: SelectorSpec,\n\t\taction: string,\n\t\targs: Record<string, unknown>,\n\t): Promise<TResult> {\n\t\tconst script = `(() => {\n\t\t\tconst spec = ${JSON.stringify(spec)};\n\t\t\tconst action = ${JSON.stringify(action)};\n\t\t\tconst args = ${JSON.stringify(args)};\n\t\t\t${PAGE_SELECTOR_HELPERS}\n\t\t\tconst element = findElement(spec);\n\t\t\tif (!element) throw new Error(\"No element matched \" + spec.raw);\n\t\t\tif (action !== \"exists\") element.scrollIntoView({ block: \"center\", inline: \"center\" });\n\t\t\tswitch (action) {\n\t\t\t\tcase \"click\":\n\t\t\t\t\tmouseEvent(element, \"mousedown\");\n\t\t\t\t\tmouseEvent(element, \"mouseup\");\n\t\t\t\t\tif (typeof element.click === \"function\") element.click();\n\t\t\t\t\telse mouseEvent(element, \"click\");\n\t\t\t\t\treturn true;\n\t\t\t\tcase \"dblclick\":\n\t\t\t\t\tmouseEvent(element, \"dblclick\");\n\t\t\t\t\treturn true;\n\t\t\t\tcase \"hover\":\n\t\t\t\t\tmouseEvent(element, \"mouseover\");\n\t\t\t\t\tmouseEvent(element, \"mouseenter\");\n\t\t\t\t\tmouseEvent(element, \"mousemove\");\n\t\t\t\t\treturn true;\n\t\t\t\tcase \"focus\":\n\t\t\t\t\tif (typeof element.focus === \"function\") element.focus();","sourceCodeStart":892,"sourceCodeEnd":928,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/browser/cmux/cmux-tab.ts#L892-L928","documentation":"CmuxTab's selector actions build an in-page script that calls findElement(spec); when no element matches the selector spec, the page side throws 'No element matched <spec.raw>', surfaced as this ToolError. This is the generic 'selector did not match anything' error for click/fill/type/check/select/exists-style actions on the cmux surface.","triggerScenarios":"Calling tab.click/tab.fill/tab.type/tab.select/tab.check with a CSS selector, text selector, or role spec that matches no element at action time: typo in the selector, element inside an iframe not reachable by the helper, element not yet rendered, wrong frame/page, or selector depending on auto-generated attributes that changed.","commonSituations":"Selectors written for a different DOM state (before login, before modal opens); framework class-name hashing changing between environments; elements in shadow DOM or iframes the PAGE_SELECTOR_HELPERS don't traverse; React 18 concurrent rendering delaying mount past the action; using text-match selectors whose label text changed (i18n, whitespace).","solutions":["Wait for the element first: await tab.waitForSelector(sel) (with a generous timeout) before performing the action.","Verify the selector matches by testing it in-page: tab.evaluate((s) => !!document.querySelector(s), sel), and adjust (prefer data-testid or id).","Check whether the element lives in an iframe or shadow root — switch to the right frame or use a deep/role-based selector the helpers support.","Re-check for typos and dynamic text: copy the exact visible label/attribute from a live tab.evaluate(document.body.innerHTML) snapshot."],"exampleFix":"// before: act immediately, element not yet mounted\nawait tab.fill(\"#email\", \"user@example.com\");\n// after: wait for the element, then act\nawait tab.waitForSelector(\"#email\", { timeout: 10_000 });\nawait tab.fill(\"#email\", \"user@example.com\");","handlingStrategy":"validation","validationCode":"const matches = await tab.evaluate(\n  (sel) => document.querySelectorAll(sel).length,\n  \"#email\",\n);\nif (matches === 0) await tab.waitForSelector(\"#email\", { timeout: 10_000 });","typeGuard":null,"tryCatchPattern":"try {\n  await tab.fill(\"#email\", \"user@example.com\");\n} catch (err) {\n  if (err instanceof ToolError && err.message.startsWith(\"No element matched\")) {\n    await tab.waitForSelector(\"#email\", { timeout: 10_000 });\n    await tab.fill(\"#email\", \"user@example.com\");\n  } else throw err;\n}","preventionTips":["waitForSelector before every selector-based action on dynamically rendered pages","Validate selectors in-page with querySelector before scripting around them","Use stable attributes (data-testid, id, aria roles) instead of hashed classes or visible text","Check for iframe/shadow-DOM boundaries the selector helpers cannot cross"],"tags":["browser","selector","dom","element-not-found"],"backgroundTag":"selector-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}